-(void)alertOKCancelAction
{
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Return Home" message:@"Are
you sure you want to return to the menu?" delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
-(void)alertConnectionLost
{
// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Lost"
message:@"The connection to the other device has been lost" delegate:self
cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
}
else
{
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
As you can see above, I have 2 alerts. But they both call the same method to handle there key presses. How can I tell which alert is currently alive and respond to the keypresses differently depending on which alert is up?