Skip to content

Instantly share code, notes, and snippets.

@iccir
Last active September 6, 2015 00:31
Show Gist options
  • Save iccir/d411b60423a42b16687e to your computer and use it in GitHub Desktop.
Save iccir/d411b60423a42b16687e to your computer and use it in GitHub Desktop.
MakeAlert()
extern UIAlertController *MakeAlert(NSString *title, NSString *message, NSString *cancelText, NSString *confirmText, void (^confirmBlock)(BOOL confirmed));
extern UIAlertController *MakeAlert(NSString *title, NSString *message, NSString *cancelText, NSString *confirmText, void (^confirmBlock)(BOOL confirmed))
{
UIAlertController *result = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
if (!confirmText) confirmText = NSLocalizedString(@"OK", nil);
if (!cancelText) cancelText = NSLocalizedString(@"Cancel", nil);
[result addAction:[UIAlertAction actionWithTitle:cancelText style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
if (confirmBlock) confirmBlock(NO);
}]];
[result addAction:[UIAlertAction actionWithTitle:confirmText style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
if (confirmBlock) confirmBlock(YES);
}]];
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment