diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 673f872..62ebf04 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -109,6 +109,7 @@ AF7069A02880F0EB00077CF6 /* ActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */; }; AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF787412286DEF8B00670588 /* ActionBackHandler.swift */; }; AF8D13392774EA1D008AF4A9 /* ActionOpenUrlHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */; }; + AFA4931E29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */; }; AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */; }; AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -133,8 +134,6 @@ AFBB96951FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96771FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96961FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96781FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */; }; - AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */; }; AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */; }; AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -273,6 +272,7 @@ AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPageHandler.swift; sourceTree = ""; }; AF787412286DEF8B00670588 /* ActionBackHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackHandler.swift; sourceTree = ""; }; AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlHandler.swift; sourceTree = ""; }; + AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionUtility+Extension.swift"; sourceTree = ""; }; AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreErrorConstants.h; sourceTree = ""; }; AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreErrorConstants.m; sourceTree = ""; }; AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadDelegateProtocol.h; sourceTree = ""; }; @@ -297,8 +297,6 @@ AFBB96771FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCorePresentationDelegateProtocol.h; sourceTree = ""; }; AFBB96781FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCorePresentViewControllerOperation.h; sourceTree = ""; }; AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCorePresentViewControllerOperation.m; sourceTree = ""; }; - AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertController.h; sourceTree = ""; }; - AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertController.m; sourceTree = ""; }; AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreDispatchUtility.h; sourceTree = ""; }; AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreDispatchUtility.m; sourceTree = ""; }; AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGetterUtility.h; sourceTree = ""; }; @@ -391,7 +389,6 @@ 8876D5D41FB50AAB00EB2E3D /* Utility */, AF43A7191FC5BE9E008E9347 /* MainProtocols */, AFBB96B41FBA3CEC0008D868 /* ActionHandling */, - AFBB967A1FBA3A9A0008D868 /* AlertHandling */, AFBB966B1FBA3A9A0008D868 /* PresentationHandling */, AFBB96361FBA39E70008D868 /* LoadHandling */, AFBB96131FBA26650008D868 /* ViewControllerMapping */, @@ -611,15 +608,6 @@ path = PresentationHandling; sourceTree = ""; }; - AFBB967A1FBA3A9A0008D868 /* AlertHandling */ = { - isa = PBXGroup; - children = ( - AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */, - AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */, - ); - path = AlertHandling; - sourceTree = ""; - }; AFBB96AB1FBA3B590008D868 /* Helpers */ = { isa = PBXGroup; children = ( @@ -630,6 +618,7 @@ D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */, AF43A5851FBB67D6008E9347 /* MVMCoreActionUtility.h */, AF43A5861FBB67D6008E9347 /* MVMCoreActionUtility.m */, + AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */, ); path = Helpers; sourceTree = ""; @@ -756,7 +745,6 @@ 8876D5EC1FB50AB000EB2E3D /* NSDictionary+MFConvenience.h in Headers */, AFFCFA651FCCC0D700FD0730 /* MVMCoreLoadingOverlayDelegateProtocol.h in Headers */, AF1201832108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h in Headers */, - AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */, 881D26961FCC9D180079C521 /* MVMCoreOperation.h in Headers */, 8876D5EA1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.h in Headers */, AF43A7201FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h in Headers */, @@ -905,7 +893,6 @@ BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */, D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */, 01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */, - AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */, 881D26941FCC9D180079C521 /* MVMCoreOperation.m in Sources */, AFED77A41FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.m in Sources */, 01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */, @@ -916,6 +903,7 @@ AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */, D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */, AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */, + AFA4931E29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift in Sources */, 1DAD0FFE26AAB40000216E83 /* ActionRunJavaScriptModel.swift in Sources */, 946EE1AB237B5C940036751F /* Decoder.swift in Sources */, 2723337D28BD53C2004EAEE0 /* Date+Extension.swift in Sources */, diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift index 5975af9..c206300 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift @@ -129,7 +129,7 @@ public protocol MVMCoreJSONActionHandlerProtocol: MVMCoreActionHandlerProtocol { } /// Logs the error. - @objc open func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable: Any]?) { + @objc open func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable: Any]? = nil, delegateObject: DelegateObject? = nil) { guard error.logError else { return } MVMCoreLoggingHandler.addError(toLog: error) error.logError = false // Further attempts to log the same error will be skipped. (Legacy action flow.) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h deleted file mode 100644 index e38bedf..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// MVMCoreAlertController.h -// alerts -// -// Created by Scott Pfeil on 10/22/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// -// 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 -@class MVMCoreAlertObject; - -@interface MVMCoreAlertController : UIAlertController - -@property (nonatomic, readonly, getter=isVisible) BOOL visible; -@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject; - -@end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m deleted file mode 100644 index 11c6fd2..0000000 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ /dev/null @@ -1,49 +0,0 @@ -// -// MVMAlertController.m -// alerts -// -// Created by Scott Pfeil on 10/22/14. -// Copyright (c) 2014 Verizon Wireless. All rights reserved. -// - -#import "MVMCoreAlertController.h" -#import "MVMCoreLoggingHandler.h" -#import "MVMCoreGetterUtility.h" - -@interface MVMCoreAlertController () - -@property (nonatomic, readwrite, getter=isVisible) BOOL visible; - -@end - -@implementation MVMCoreAlertController - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - - [self willChangeValueForKey:@"isVisible"]; - self.visible = YES; - [self didChangeValueForKey:@"isVisible"]; - [MVMCoreLoggingHandler logAlertForAlertController:self]; -} - -- (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; - [self willChangeValueForKey:@"isVisible"]; - self.visible = NO; - [self didChangeValueForKey:@"isVisible"]; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"%@|title=%@|message=%@", [super description],self.title,self.message]; -} - -- (UIInterfaceOrientationMask)supportedInterfaceOrientations { - if ([MVMCoreGetterUtility isOnIPad]) { - return UIInterfaceOrientationMaskAll; - } else { - return UIInterfaceOrientationMaskPortrait; - } -} - -@end diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h index 39ddc8b..db6f5b9 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadDelegateProtocol.h @@ -11,7 +11,6 @@ #import @class MVMCoreRequestParameters; @class MVMCoreErrorObject; -@class MVMCoreAlertObject; @class MVMCoreLoadObject; @protocol MVMCoreLoadDelegateProtocol diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index 8e1a01f..be93c59 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -63,7 +63,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import -#import // Action Handling #import diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index b8ae254..fc0e353 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -7,7 +7,6 @@ // #import -@class MVMCoreAlertController; @protocol MVMCoreLoggingDelegateProtocol @@ -25,7 +24,4 @@ // Log that the load has finished. - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; -// Log alert -- (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; - @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h index d81869f..4cd0b53 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h @@ -11,7 +11,6 @@ #import #import #import -@class MVMCoreAlertController; #define MVMCoreLog(fmt, ...) \ [MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]]; @@ -24,7 +23,6 @@ + (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; -+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController; - (void)recordEvent:(nonnull NSString *)name attributes:(nullable NSDictionary *)attributes; #pragma mark MVMCoreLoggingDelegateProtocol diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index 9765925..4fb541a 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -45,12 +45,6 @@ } } -+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController { - if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertController:)]) { - [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertController:alertController]; - } -} - - (void)recordEvent:(nonnull NSString *)name attributes:(nullable NSDictionary *)attributes {} #pragma mark - logging delegate diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h index 86c056d..8548c81 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.h @@ -136,9 +136,6 @@ // Use this to dismiss all presented view controllers stacked on the bottom one. - (void)dismissToBottom:(BOOL)animated; -// Removes all queued up items. -- (void)cancelPresentation; - #pragma mark - Presentation Extra // Use this to present. diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m index 15aea59..a721f50 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m @@ -46,9 +46,6 @@ self.navigationQueue = [[NSOperationQueue alloc] init]; self.navigationQueue.maxConcurrentOperationCount = 1; - self.presentationQueue = [[NSOperationQueue alloc] init]; - self.presentationQueue.maxConcurrentOperationCount = 1; - self.delegates = (NSHashTable *)[NSHashTable weakObjectsHashTable]; } return self; @@ -308,10 +305,6 @@ [self dismissToBottom:animated delegate:nil completionHandler:NULL]; } -- (void)cancelPresentation { - [self.presentationQueue cancelAllOperations]; -} - #pragma mark - Presentation Extra - (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject*)delegate completionHandler:(nullable void (^)(void))completionBlock { @@ -325,7 +318,7 @@ MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:viewController animated:animated]; operation.delegate = delegate; operation.completionBlock = completionBlock; - [self.presentationQueue addOperation:operation]; + [self.navigationQueue addOperation:operation]; } }]; } diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentViewControllerOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentViewControllerOperation.m index 6b7c51b..0e757ab 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentViewControllerOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentViewControllerOperation.m @@ -7,7 +7,6 @@ // #import "MVMCorePresentViewControllerOperation.h" -#import "MVMCoreAlertController.h" #import "MVMCorePresentAnimationOperation.h" #import "MVMCoreDispatchUtility.h" #import "MVMCoreConstants.h" @@ -18,20 +17,10 @@ @property (nullable, strong, nonatomic) UIViewController *presentedViewController; @property (nonatomic) BOOL animate; -@property (nonatomic) BOOL beingObserved; -@property (nullable, weak, nonatomic) MVMCoreAlertController *alertController; - @end @implementation MVMCorePresentViewControllerOperation -// The context for kvo -static void * XXContext = &XXContext; - -- (void)dealloc { - [self stopObservingAlertView]; -} - - (nullable instancetype)initWithPresentingViewController:(nullable UIViewController *)presentingViewController presentedViewController:(nullable UIViewController *)presentedViewController animated:(BOOL)animated { if (self = [super init]) { @@ -67,57 +56,19 @@ static void * XXContext = &XXContext; controllerToPresentOn = controllerToPresentOn.presentedViewController; } - // If an alert is showing, don't present until the alerts are dismissed. - if ([controllerToPresentOn isKindOfClass:[MVMCoreAlertController class]]) { - [self observeForAlertDismissal:(MVMCoreAlertController *)controllerToPresentOn]; - } else { - MVMCorePresentAnimationOperation *animationOperation = [[MVMCorePresentAnimationOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:self.presentedViewController animated:self.animate]; - animationOperation.delegate = self.delegate; - [animationOperation setCompletionBlock:^{ - [self markAsFinished]; - // Notify that page has changed - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationViewControllerChanged object:nil]; - }); - }]; - [[NSOperationQueue mainQueue] addOperation:animationOperation]; - } + MVMCorePresentAnimationOperation *animationOperation = [[MVMCorePresentAnimationOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:self.presentedViewController animated:self.animate]; + animationOperation.delegate = self.delegate; + [animationOperation setCompletionBlock:^{ + [self markAsFinished]; + // Notify that page has changed + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationViewControllerChanged object:nil]; + }); + }]; + [[NSOperationQueue mainQueue] addOperation:animationOperation]; } else { [self markAsFinished]; } } -- (void)cancel { - [super cancel]; - [self stopObservingAlertView]; -} - -#pragma mark - Observer Functions - -- (void)observeForAlertDismissal:(MVMCoreAlertController *)alertController { - if (!self.beingObserved) { - self.beingObserved = YES; - self.alertController = alertController; - [alertController addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:XXContext]; - } -} - -- (void)stopObservingAlertView { - if (self.beingObserved) { - [self.alertController removeObserver:self forKeyPath:@"visible" context:XXContext]; - self.alertController = nil; - self.beingObserved = NO; - } -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - - if (context == XXContext && [keyPath isEqualToString:@"visible"]) { - if (![object isVisible]) { - [self stopObservingAlertView]; - [self present]; - } - } -} - @end diff --git a/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility+Extension.swift b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility+Extension.swift new file mode 100644 index 0000000..f6b45ce --- /dev/null +++ b/MVMCore/MVMCore/Utility/Helpers/MVMCoreActionUtility+Extension.swift @@ -0,0 +1,19 @@ +// +// MVMCoreActionUtility+Extension.swift +// MVMCore +// +// Created by Scott Pfeil on 4/11/23. +// Copyright © 2023 myverizon. All rights reserved. +// + +public extension MVMCoreActionUtility { + static func fatalClassCheck(object: AnyObject?) -> T { + guard let object = object else { + fatalError("Object \(T.self) is nil.") + } + guard let instance = object as? T else { + fatalError("\(object) is not an instance of \(T.self)") + } + return instance + } +}