From bffb93660d295c6a843d7486bc7d7daaa8107151 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 30 Oct 2018 17:32:59 -0400 Subject: [PATCH] changes to the way popup delegacy works --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 2 -- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 1 - MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 3 +-- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 21ea9e6..e38bedf 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -8,13 +8,11 @@ // Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler. #import -#import @class MVMCoreAlertObject; @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; @property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; -@property (nullable, nonatomic, weak) NSObject *delegate; @end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 684a382..673c591 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -8,7 +8,6 @@ #import "MVMCoreAlertController.h" #import "MVMCoreLoggingHandler.h" -#import "MVMCoreAlertObject.h" @interface MVMCoreAlertController () diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index 642b073..5d5f93b 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -81,7 +81,7 @@ } - (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { - + // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { [self removeAllAlertViews]; @@ -89,7 +89,6 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; - alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; if (action) { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index aa82631..06cec60 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -50,6 +50,7 @@ __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; alert.title = [responseInfo stringForKey:KeyErrorHeading]; alert.message = [responseInfo stringForKey:KeyUserMessage]; + alert.alertDelegate = actionDelegate; NSString *messageStyle = [responseInfo stringForKey:KeyMessageStyle]; if ([ValueTypeFieldErrors isEqualToString:[responseInfo string:KeyType]]) { @@ -71,6 +72,7 @@ // Perform a popup. alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; + // Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button). NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"]; [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { @@ -87,8 +89,6 @@ alert = popupAlert; } }]; - alert.pageType = pageTypeForPopup; - alert.alertDelegate = actionDelegate; } else if (messageStyle.length == 0 && pageType) { // No message style!