Last active
October 19, 2019 09:15
-
-
Save LeeKahSeng/0e1bf5ef92a7b8925dbd8f6c22a77f1a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct AppData { | |
private static let enableAutoLoginKey = "enable_auto_login_key" | |
private static let usernameKey = "username_key" | |
static var enableAutoLogin: Bool { | |
get { | |
// Read from UserDefaults | |
return UserDefaults.standard.bool(forKey:enableAutoLoginKey) | |
} | |
set { | |
// Save to UserDefaults | |
UserDefaults.standard.set(newValue, forKey: enableAutoLoginKey) | |
} | |
} | |
static var username: String { | |
get { | |
// Read from UserDefaults | |
return UserDefaults.standard.string(forKey: usernameKey) ?? "" | |
} | |
set { | |
// Save to UserDefaults | |
UserDefaults.standard.set(newValue, forKey: usernameKey) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment