When a warning is displayed, set the tag property to different values. This is just an integer and can be requested in the callback / delegation method.
Here is an example (using an ActionSheet, not an AlertView, but the principle is exactly the same):
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Some option", nil]; actionSheet.actionSheetStyle = UIActionSheetStyleDefault; actionSheet.tag = 10; [actionSheet showInView:self.view]; [actionSheet release];
Then in your selector:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { switch (actionSheet.tag) { case 10: // do stuff break; case 20: // do other stuff break; } }
Of course, you should use constants, not literal values, localized strings, etc., but this is the main idea.
source share