File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,15 @@ + (void)showAlertWithTitle:(NSString *)title
3131 message: message
3232 preferredStyle: UIAlertControllerStyleAlert];
3333
34- void (^alertActionHandler)(UIAlertAction *) = [^(UIAlertAction *action){
35- // This block intentionally retains alertController, and releases it afterwards.
36- if (action.style == UIAlertActionStyleCancel) {
37- completion (NSNotFound );
38- } else {
39- NSUInteger index = [alertController.actions indexOfObject: action];
40- completion (index - 1 );
34+ void (^alertActionHandler)(UIAlertAction *) = [^(UIAlertAction *action) {
35+ if (completion) {
36+ // This block intentionally retains alertController, and releases it afterwards.
37+ if (action.style == UIAlertActionStyleCancel) {
38+ completion (NSNotFound );
39+ } else {
40+ NSUInteger index = [alertController.actions indexOfObject: action];
41+ completion (index - 1 );
42+ }
4143 }
4244 alertController = nil ;
4345 } copy];
@@ -49,7 +51,7 @@ + (void)showAlertWithTitle:(NSString *)title
4951 for (NSString *buttonTitle in otherButtonTitles) {
5052 [alertController addAction: [UIAlertAction actionWithTitle: buttonTitle
5153 style: UIAlertActionStyleDefault
52- handler: alertActionHandler]];
54+ handler: alertActionHandler]];
5355 }
5456
5557 UIWindow *keyWindow = [UIApplication sharedApplication ].keyWindow ;
You can’t perform that action at this time.
0 commit comments