// // Copyright © 2018 Jimmy. All rights reserved. // #import "LCAlertController.h" @implementation LCAlertController + (LCAlertController *)showWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitle:(NSString *)otherButtonTitle handler:(LCAlertControllerHandler)handler { LCAlertController *alertController = [LCAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; if (cancelButtonTitle != nil) { UIAlertAction *cancelAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: ^(UIAlertAction * _Nonnull action) { if (handler) { handler(0); } }]; [alertController addAction: cancelAction]; } if (otherButtonTitle != nil) { UIAlertAction *otherAction = [UIAlertAction actionWithTitle: otherButtonTitle style: UIAlertActionStyleDefault handler: ^(UIAlertAction * _Nonnull action) { if (handler) { handler(1); } }]; [alertController addAction: otherAction]; } UIViewController *topVc = [self topPresentOrRootController]; [topVc presentViewController:alertController animated:true completion:nil]; return alertController; } + (LCAlertController *)showWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles handler:(LCAlertControllerHandler)handler { LCAlertController *alertController = [LCAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; if (cancelButtonTitle != nil) { UIAlertAction *cancelAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: ^(UIAlertAction * _Nonnull action) { if (handler) { handler(0); } }]; [alertController addAction: cancelAction]; } if (otherButtonTitles.count > 0) { for (int i = 0; i *)otherButtonTitles handler:(LCAlertControllerHandler)handler { LCAlertController *alertController = [LCAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; if (cancelButtonTitle != nil) { UIAlertAction *cancelAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: ^(UIAlertAction * _Nonnull action) { if (handler) { handler(0); } }]; [alertController addAction: cancelAction]; } if (otherButtonTitles.count > 0) { for (int i = 0; i