Skip to content

Instantly share code, notes, and snippets.

@sag333ar
Last active December 28, 2015 09:59
Show Gist options
  • Save sag333ar/7482696 to your computer and use it in GitHub Desktop.
Save sag333ar/7482696 to your computer and use it in GitHub Desktop.
Show Alertview with one-line of code & also detect alertview with tag. Examples are as follows ALERT_WITH_TAG(100, @"Message", @"send this request", nil, self, @"Yes", @"No",nil); ALERT_WITH_TAG(100, @"Message", @"Data deleted", @"Okay", self, nil);
void ALERT_WITH_TAG(NSUInteger tag,NSString *title, NSString *message,NSString *canceBtnTitle,id delegate,NSString *otherButtonTitles, ... )
{
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:title
message:message
delegate:delegate
cancelButtonTitle:canceBtnTitle
otherButtonTitles:nil
];
va_list args;
va_start(args, otherButtonTitles);
NSString *obj;
for (obj = otherButtonTitles; obj != nil; obj = va_arg(args, NSString*))
[alertView addButtonWithTitle:obj];
va_end(args);
alertView.tag = tag;
[alertView show];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment