From 86d957c29b35503b4c53f2eca4c34c8ba398878a Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 19 Mar 2022 11:53:06 -0400 Subject: [PATCH] Update DataStore.swift --- Clocker/Overall App/DataStore.swift | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Clocker/Overall App/DataStore.swift b/Clocker/Overall App/DataStore.swift index c9efbc2..1a51174 100644 --- a/Clocker/Overall App/DataStore.swift +++ b/Clocker/Overall App/DataStore.swift @@ -27,6 +27,11 @@ class DataStore: NSObject { // Since these pref can accessed every second, let's cache this private var shouldDisplayDayInMenubar: Bool = false private var shouldDisplayDateInMenubar: Bool = false + private static let timeFormatsWithSuffix: Set = Set([NSNumber(integerLiteral: 0), + NSNumber(integerLiteral: 3), + NSNumber(integerLiteral: 4), + NSNumber(integerLiteral: 6), + NSNumber(integerLiteral: 7)]) class func shared() -> DataStore { return sharedStore @@ -101,23 +106,10 @@ class DataStore: NSObject { userDefaults.set(currentLineup, forKey: CLDefaultPreferenceKey) } - private func shouldDisplayHelper(_ key: String) -> Bool { - guard let value = retrieve(key: key) as? NSNumber else { - return false - } - return value.isEqual(to: NSNumber(value: 0)) - } - func timezoneFormat() -> NSNumber { return userDefaults.object(forKey: CLSelectedTimeZoneFormatKey) as? NSNumber ?? NSNumber(integerLiteral: 0) } - static let timeFormatsWithSuffix: Set = Set([NSNumber(integerLiteral: 0), - NSNumber(integerLiteral: 3), - NSNumber(integerLiteral: 4), - NSNumber(integerLiteral: 6), - NSNumber(integerLiteral: 7)]) - func isBufferRequiredForTwelveHourFormats() -> Bool { return DataStore.timeFormatsWithSuffix.contains(timezoneFormat()) } @@ -165,4 +157,13 @@ class DataStore: NSObject { return value == 0 } } + + //MARK: Private + + private func shouldDisplayHelper(_ key: String) -> Bool { + guard let value = retrieve(key: key) as? NSNumber else { + return false + } + return value.isEqual(to: NSNumber(value: 0)) + } }