Last active
February 24, 2025 20:45
-
-
Save Erica-Iris/56b9ff177642b993cf3bcb90c26334ae to your computer and use it in GitHub Desktop.
保存到app default
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
private let defaults = UserDefaults.standard | |
private let usernameKey = "username" | |
private let passwordKey = "password" | |
func saveLoginInfo(username: String, password: String) { | |
defaults.set(username, forKey: usernameKey) | |
defaults.set(password, forKey: passwordKey) | |
} | |
func getSavedUsername() -> String { | |
return defaults.string(forKey: usernameKey) ?? "" | |
} | |
func getSavedPassword() -> String { | |
return defaults.string(forKey: passwordKey) ?? "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment