From e8553e717e429481f3a0d6a7f9a768ae54338ba0 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 24 Jun 2022 10:39:15 -0400 Subject: [PATCH 1/2] Crash fix for tab bar indices out of bounds. --- .../MVMCoreUISplitViewController+Extension.swift | 8 +++++--- .../SplitViewController/MVMCoreUISplitViewController.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index 3c6c878b..c6ec9382 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -46,17 +46,19 @@ public extension MVMCoreUISplitViewController { tabBar?.highlightTab(at: index) } else if let index = mvmViewController?.loadObject??.requestParameters?.actionMap?["tabBarIndex"] as? Int { tabBar?.highlightTab(at: index) - } else if navigationIndex < tabBarIndices.count { - let index = (tabBarIndices[navigationIndex] as! NSNumber).intValue + } else if navigationIndex < tabBarIndices.count, + let index = (tabBarIndices[navigationIndex] as? NSNumber)?.intValue { tabBar?.highlightTab(at: index) } // Store current tab index, so we can switch back when going back in hierarchy. - if tabBarIndices.count > 0 { + if tabBarIndices.count > navigationIndex { tabBarIndices.removeObjects(in: NSRange(location: navigationIndex, length: tabBarIndices.count - navigationIndex)) } if let currentIndex = tabBar?.currentTabIndex() { tabBarIndices.add(NSNumber(integerLiteral: currentIndex)) + } else { + tabBarIndices.add(NSNull()) } // Show/Hide. In terms of priority, Page > Action > Always Show. diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index d0530cc9..589c1cbb 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -55,7 +55,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Reference to the tabbar. @property (nullable, weak, nonatomic) UIView *tabBar; -/// Tab bar index history. +/// Tab bar index history. Contains either indices (0, 1, etc) or NSNull if there was no tab bar indice to set. @property (nonnull, strong, nonatomic) NSMutableArray *tabBarIndices; // Convenience getter From 76b88e712144e570c094999663d7dadac2e9b624 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 24 Jun 2022 13:13:52 -0400 Subject: [PATCH 2/2] Fix top notification check --- MVMCoreUI/Alerts/MVMCoreAlertHandler+Extension.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler+Extension.swift b/MVMCoreUI/Alerts/MVMCoreAlertHandler+Extension.swift index b0158e2d..6f52ce93 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler+Extension.swift +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler+Extension.swift @@ -52,7 +52,9 @@ public extension MVMCoreAlertHandler { extension MVMCoreAlertHandler: MVMCorePresentationDelegateProtocol { // Update displayable for each top alert operation when page type changes, in top queue priority order. public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) { - guard navigationController == MVMCoreUISplitViewController.main()?.navigationController else { return } + guard topAlertQueue.operations.count > 0 else { return } + let viewController = MVMCoreUIUtility.getViewControllerTraversingManagers(viewController) + guard viewController == MVMCoreUISplitViewController.main()?.getCurrentViewController() else { return } let pageType = (viewController as? MVMCoreViewControllerProtocol)?.pageType topAlertQueue.operations.compactMap { $0 as? MVMCoreTopAlertOperation