To show the alert:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Do you want to say hello?"
message:@"More info..."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Say Hello",nil];
[alert show];
[alert release];
To respond to whatever button was tapped:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"Cancel Tapped.");
}
else if (buttonIndex == 1) {
NSLog(@"OK Tapped. Hello World!");
}
}
For more information, see the UIAlertView Class Reference and the UIAlertView Delegate Protocol Reference.