default presentation view controller.

Re-use function
This commit is contained in:
Pfeil, Scott Robert 2019-01-25 17:38:06 -05:00
parent 30b875b2ab
commit 2510db98e0

View File

@ -276,12 +276,13 @@
- (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)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];