diff --git a/MVMCoreUI/Containers/NavigationController.swift b/MVMCoreUI/Containers/NavigationController.swift index bcbf927e..6176427f 100644 --- a/MVMCoreUI/Containers/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController.swift @@ -108,16 +108,16 @@ import UIKit /// Convenience function to return the navigation model of the lowest controller traversing managers public static func getNavigationModel(from viewController: UIViewController) -> NavigationItemModelProtocol? { - let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) - guard let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } + guard let controller = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController), + let model = (controller as? PageProtocol)?.pageModel?.navigationBar else { return nil } return model } } extension NavigationController: MVMCoreViewManagerProtocol { // TODO: change this to optional - public func getCurrentViewController() -> UIViewController { - return topViewController! + public func getCurrentViewController() -> UIViewController? { + return topViewController } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 835a2df9..a62a3788 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -119,8 +119,8 @@ public extension MVMCoreUISplitViewController { } extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { - public func getCurrentViewController() -> UIViewController { - navigationController!.getCurrentViewController() + public func getCurrentViewController() -> UIViewController? { + navigationController?.getCurrentViewController() } public func containsPage(withPageType pageType: String?) -> Bool { diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 171ebeea..c6959723 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -32,10 +32,10 @@ NS_ASSUME_NONNULL_BEGIN + (UIEdgeInsets)getMarginsForView:(nullable UIView *)view; /// Gets the current visible view controller. Checks presented view controllers first, and then it checks on the NavigationController in the session object. -+ (UIViewController *)getCurrentVisibleController; ++ (nullable UIViewController *)getCurrentVisibleController; /// Gets the first non manager controller. -+ (UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; ++ (nullable UIViewController *)getViewControllerTraversingManagers:(UIViewController *)viewController; /// Checks if the view or any descendents of the view is currently focused for voice over. + (BOOL)viewContainsAccessiblityFocus:(nonnull UIView *)view;