Skip to content

Instantly share code, notes, and snippets.

@macecchi
Created August 20, 2015 13:01
Show Gist options
  • Save macecchi/ada255f4950e3e002b16 to your computer and use it in GitHub Desktop.
Save macecchi/ada255f4950e3e002b16 to your computer and use it in GitHub Desktop.
Category with simple static method to present an alert with an "OK" button using iOS lib PSTAlertController
#import <PSTAlertController.h>
@interface PSTAlertController (okAlert)
+ (PSTAlertController *)presentOkAlertWithTitle:(NSString *)title andMessage:(NSString *)message;
+ (PSTAlertController *)presentOkAlertWithTitle:(NSString *)title andMessage:(NSString *)message andHandler:(void (^)(PSTAlertAction *action))handler;
@end
#import "PSTAlertController+okAlert.h"
@implementation PSTAlertController (okAlert)
+ (PSTAlertController *)presentOkAlertWithTitle:(NSString *)title andMessage:(NSString *)message andHandler:(void (^)(PSTAlertAction *))handler {
PSTAlertController *alertController = [PSTAlertController alertWithTitle:title message:message];
[alertController addAction:[PSTAlertAction actionWithTitle:@"OK" handler:handler]];
[alertController showWithSender:nil controller:nil animated:YES completion:nil];
return alertController;
}
+ (PSTAlertController *)presentOkAlertWithTitle:(NSString *)title andMessage:(NSString *)message {
return [PSTAlertController presentOkAlertWithTitle:title andMessage:message andHandler:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment