Created
January 20, 2015 08:52
-
-
Save valvoline/528922fd0e0865599dac to your computer and use it in GitHub Desktop.
Simple category that wraps around the UIAlertController annoying stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIAlertController+Utilities.h | |
// | |
// Created by valvoline on 18/12/14. | |
// Copyright (c) 2014 sofapps. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface UIAlertController (Utilities) | |
+ (UIAlertController*)alertControllerWithTitle:(NSString *)aTitle | |
message:(NSString *)aMessage | |
actions:(UIAlertAction *)cancelAct,...; | |
+ (UIAlertController*)sheetControllerWithTitle:(NSString *)aTitle | |
message:(NSString *)aMessage | |
actions:(UIAlertAction *)cancelAct, ...; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIAlertController+Utilities.m | |
// | |
// Created by valvoline on 18/12/14. | |
// Copyright (c) 2014 sofapps. All rights reserved. | |
// | |
#import "UIAlertController+Utilities.h" | |
@implementation UIAlertController (Utilities) | |
+ (UIAlertController*)alertControllerWithTitle:(NSString *)aTitle | |
message:(NSString *)aMessage | |
actions:(UIAlertAction *)cancelAct, ... | |
{ | |
va_list args; | |
va_start(args, cancelAct); | |
UIAlertController *alert = [UIAlertController alertControllerWithTitle:aTitle | |
message:aMessage | |
preferredStyle:UIAlertControllerStyleAlert]; | |
for (UIAlertAction *anAct = cancelAct; anAct != nil; anAct = va_arg(args, UIAlertAction*)) | |
{ | |
[alert addAction:anAct]; | |
} | |
va_end(args); | |
return alert; | |
} | |
+ (UIAlertController*)sheetControllerWithTitle:(NSString *)aTitle | |
message:(NSString *)aMessage | |
actions:(UIAlertAction *)cancelAct, ... | |
{ | |
va_list args; | |
va_start(args, cancelAct); | |
UIAlertController *alert = [UIAlertController alertControllerWithTitle:aTitle | |
message:aMessage | |
preferredStyle:UIAlertControllerStyleActionSheet]; | |
for (UIAlertAction *anAct = cancelAct; anAct != nil; anAct = va_arg(args, UIAlertAction*)) | |
{ | |
[alert addAction:anAct]; | |
} | |
va_end(args); | |
return alert; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment