From 524a7383ac279aa53849dfea77429e5f3408ead2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 4 Nov 2019 11:35:45 -0600 Subject: [PATCH] Don't create a new instance of userdefaults each time it is used. --- iOS/AppDefaults.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 09cd6a317..b70fc710a 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -10,11 +10,11 @@ import UIKit struct AppDefaults { - static var shared: UserDefaults { + static var shared: UserDefaults = { let appIdentifierPrefix = Bundle.main.object(forInfoDictionaryKey: "AppIdentifierPrefix") as! String let suiteName = "\(appIdentifierPrefix)group.\(Bundle.main.bundleIdentifier!)" return UserDefaults.init(suiteName: suiteName)! - } + }() struct Key { static let lastImageCacheFlushDate = "lastImageCacheFlushDate"