Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 1.1 KB

README.md

File metadata and controls

27 lines (24 loc) · 1.1 KB

UIAlertController-Quickie

A small Objective-C category that allows creating a UIAlertView with 1 line of code

Usage

The old way:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:title 
                                                               message:message 
                                                        preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"Ok" 
                                                 style:UIAlertActionStyleCancel 
                                               handler:^(UIAlertAction * _Nonnull action) {
    [alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:action];
[viewController presentViewController:alert animated:YES completion:nil];

Using the UIAlertController+Quickie Category:

[UIAlertController showQuickieAlertWithTitle:@"Wow!" message:@"Hey, that was easy!"];

Or show on a specific UIViewController:

[UIAlertController showQuickieAlertWithTitle:@"Wow!" message:@"Hey, that was easy!" fromViewController:otherViewController];