I am playing around with UIAlertView and am trying to simply display an NSLog message if the user clicks on the cancel button. I just can't figure out why absolutely nothing is happening.
Here's the code that I have in place:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexpath
{
NSUInteger row = [indexpath row];
NSString *rowValue = [listData objectAtIndex:row];
NSString *message = [[NSString alloc] initWithFormat:@"Contact %@", rowValue];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Call this person"
message:message
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Call",nil];
[alert show];
[message release];
[alert release];
}
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [alert cancelButtonIndex])
{
//Just a quick write to the console
NSLog(@"You clicked on the cancel button");
//Initially tried to see if I could dial a number
//[[UIApplication sharedApplication]
//openURL:[NSURL URLWithString:@"tel://123456789"]];
}
}
I know i am missing something really obvious! Any suggestions?
Also, on a related note - This little test app is actually a table view with 10 entries populated from an Array. What I'd like to do is be able to use the array index and display a different message for each item. Given my setup below, how would I reference the tableview row in my alertView:clickedButtonAtIndex method.