diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreDismissViewControllerOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreDismissViewControllerOperation.m index 4a09cb4..fbfd950 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreDismissViewControllerOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreDismissViewControllerOperation.m @@ -8,6 +8,7 @@ #import "MVMCoreDismissViewControllerOperation.h" #import "MVMCoreConstants.h" +#import "MVMCoreDispatchUtility.h" typedef NS_ENUM(NSInteger, DismissType) { DismissTypeTop = 0, @@ -49,29 +50,31 @@ typedef NS_ENUM(NSInteger, DismissType) { return; } - switch (self.type) { - case DismissTypeTop: - { - // Gets the top most presented. - UIViewController *controllerToDismiss = self.viewController; - while (controllerToDismiss.presentedViewController) { - controllerToDismiss = controllerToDismiss.presentedViewController; + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + switch (self.type) { + case DismissTypeTop: + { + // Gets the top most presented. + UIViewController *controllerToDismiss = self.viewController; + while (controllerToDismiss.presentedViewController) { + controllerToDismiss = controllerToDismiss.presentedViewController; + } + [self dismissViewController:controllerToDismiss]; } - [self dismissViewController:controllerToDismiss]; - } - break; - case DismissTypeSpecific: - { - if (self.viewController.presentingViewController) { - [self dismissViewController:self.viewController.presentingViewController]; - } else { - [self dismissViewController:self.viewController]; + break; + case DismissTypeSpecific: + { + if (self.viewController.presentingViewController) { + [self dismissViewController:self.viewController.presentingViewController]; + } else { + [self dismissViewController:self.viewController]; + } } + break; + default: + break; } - break; - default: - break; - } + }]; } - (void)dismissViewController:(nonnull UIViewController *)viewController { 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..3f4b2a7 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]; } }]; } @@ -336,7 +329,7 @@ UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController; MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissTopViewController:controllerToPresentOn animated:animated]; operation.completionBlock = completionBlock; - [[NSOperationQueue mainQueue] addOperation:operation]; + [self.navigationQueue addOperation:operation]; }]; } @@ -344,7 +337,7 @@ MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:viewController animated:animated]; operation.completionBlock = completionBlock; - [[NSOperationQueue mainQueue] addOperation:operation]; + [self.navigationQueue addOperation:operation]; } - (void)dismissToBottom:(BOOL)animated delegate:(nullable NSObject*)delegate completionHandler:(nullable void (^)(void))completionBlock { @@ -353,7 +346,7 @@ UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController; MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:controllerToPresentOn animated:animated]; operation.completionBlock = completionBlock; - [[NSOperationQueue mainQueue] addOperation:operation]; + [self.navigationQueue addOperation:operation]; }]; }