From 8b64b2b52a458fb7ed7d23bb0de24e353dbb85a9 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Fri, 1 Dec 2023 14:32:33 -0500 Subject: [PATCH] Ensure index > 0 for those tricky ones. --- .../Molecules/HorizontalCombinationViews/TabBar.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index d0252419..65b116f5 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -84,8 +84,8 @@ import VDSColorTokens // MARK: - TabBarProtocol @MainActor public func highlightTab(at index: Int) { - guard let items = items, index < items.count else { - MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available \(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!) + guard let items = items, index >= 0, index < items.count else { + MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available .", code: 0, domain: ErrorDomainSystem, location: #function)!) return } tabModel.selectedTab = index @@ -94,8 +94,8 @@ import VDSColorTokens @MainActor public func selectTab(at index: Int) { - guard let items = items, index < items.count else { - MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available \(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!) + guard let items = items, index >= 0, index < items.count else { + MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available.", code: 0, domain: ErrorDomainSystem, location: #function)!) return } selectedItem = items[index]