Created
May 17, 2017 13:41
-
-
Save reeichert/6f9f8632ca34bf51e70ee23413628734 to your computer and use it in GitHub Desktop.
Should show tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppManager: NSObject { | |
static let userDefaults = UserDefaults.standard | |
static let shared = AppManager() | |
static let dataKey = "AppManagerDataKey" | |
static let tutorialKey = "AppManagerTutorialKey" | |
public func reset(for key: String) { | |
if var data = userDefaults.object(forKey: dataKey) as? [String: Bool] { | |
data.removeValue(forKey: key) | |
userDefaults.set(data, forKey: dataKey) | |
} | |
} | |
public func shouldShowTutorial() -> Bool { | |
if var data = userDefaults.object(forKey: dataKey) as? [String: Bool] { | |
if let _ = data[tutorialKey] { | |
return false | |
} | |
data[tutorialKey] = true | |
userDefaults.set(data, forKey: dataKey) | |
return true | |
} | |
let data = [tutorialKey: true] | |
userDefaults.set(data, forKey: dataKey) | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment