Turn this:
UIAlertController * ac = [UIAlertController alertControllerWithTitle:@"Not Nice" message:@"So many declarations and lines of code. Why do I have to remember all these types?" preferredStyle:UIAlertControllerStyleAlert];
UIAlertActon * cancelAction = [UIAlertAction actionWithTitle:@"Something Else" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"Do something else.");
}];
[ac addAction:defaultAction];
UIAlertActon * cancelAction = [UIAlertAction actionWithTitle:@"Something" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"Do something.");
}]
[ac addAction:defaultAction];
[self presentViewController:ac animated:true completion:^{
}];
into this:
UIAlertController * ac = [UIAlertController alertControllerWithTitle:@"Easy" message:@"One method. That's all." style:UIAlertControllerStyleAlert cancelButtonTitle:@"Something Else" cancelButtonBlock:^(UIAlertAction *action) {
NSLog(@"Do something else.");
} destructiveButtonTitle:nil destructiveButtonBlock:nil otherButtonTitlesAndBlocks:@"Something", ^(UIAlertAction *action) {
NSLog(@"Do something.");
}, nil];
[self presentViewController:ac animated:true completion:^{
}];
Just import the header and use the class method to make Alerts and Sheets.
To run the example project, clone the repo, and run pod install
from the Example directory first.
UIAlertController-BetterConstructor is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "UIAlertController-BetterConstructor"
Daniel Blakemore, DanBlakemore@gmail.com
UIAlertController-BetterConstructor is available under the MIT license. See the LICENSE file for more info.