From 2510db98e0cec32058210d00d4bd28fdd0d021a7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 25 Jan 2019 17:38:06 -0500 Subject: [PATCH] default presentation view controller. Re-use function --- .../MVMCore/PresentationHandling/MVMCoreNavigationHandler.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m index b6aa0aa..0feddeb 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationHandler.m @@ -276,12 +276,13 @@ - (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject*)delegate completionHandler:(nullable void (^)(void))completionBlock { - if (!self.viewControllerToPresentOn) { + UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [UIApplication sharedApplication].keyWindow.rootViewController; + if (!controllerToPresentOn) { // Log if we are attempting to add an alert to nothing. MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:nil message:@"The viewControllerToPresent on property is nil and an attempt was made to present." code:ErrorCodeNoViewControllerToPresentOn domain:ErrorDomainNative location:[NSString stringWithFormat:@"ViewController:%@|Delegate:%@",viewController.description,delegate]]; [MVMCoreLoggingHandler addErrorToLog:error]; } else { - MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:self.viewControllerToPresentOn presentedViewController:viewController animated:animated]; + MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:viewController animated:animated]; operation.delegate = delegate; operation.completionBlock = completionBlock; [self.presentationQueue addOperation:operation];