I have a table view. When a user selects a row, I would like to display a standard "Are you sure?" sort of dialog. But if they are sure some info about what to do is tied to the row they selected. How can I get access to that?
Here's what I have so far.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SitePeople *sitePersonAtIndex = [self.sitePeoples objectAtIndex:indexPath.row];
UIAlertView *alert;
alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:[NSString stringWithFormat:@"This will send an email to %@", sitePersonAtIndex.SitePerson] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
self.alertShowing = NO;
if (buttonIndex == 0)
{
//cancelled, do nothing
} else {
//SitePeople *sitePersonAtIndex = [self.sitePeoples objectAtIndex:indexPath.row];
SitePeople *sitePersonAtIndex = [self.sitePeoples objectAtIndex:[self.tableView indexPathForSelectedRow]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *email = [defaults stringForKey:@"email"];
NSString *password = [defaults stringForKey:@"password"];
[self sendEmail:[NSString stringWithFormat:@"http://service.pharmatech.com/Share/emailstudy/%@/%@/%@/%@", email, password, self.study.ProjectID, sitePersonAtIndex.SitePeopleID]];
UIAlertView *alert;
if (self.alertShowing == NO)
{
if ([self.sendEmailResult.WasSuccessful isEqual: @"true"]) {
alert = [[UIAlertView alloc] initWithTitle:@"Success" message:self.sendEmailResult.Message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
} else {
alert = [[UIAlertView alloc] initWithTitle:@"Error" message:self.sendEmailResult.Message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
}
[alert show];
}
}
}
Any tips would be appreciated. Thanks.