Reference To:http://www.jianshu.com/p/d59b004b5ea7
1. Storing configuration information with Userdefaults
Note: This time the use of Userdefaults storage information is not considered security issues under the premise.
In two cases:
1. If it is sensitive information such as password user name, please use keychain to store user sensitive information, I will write an article with keychain to store user sensitive information
2. If you set the Remember password, the first time you open the app boot app, or the General app settings, you can use the Userdefaults
In general, there are two common methods of use:
1. First login, App guide Introduction page
App-guided animations. jpg
When the user opens the app for the first time, it uses userdefaults to determine if the user has Configuration storage information, and generally declares a isfirstlaunch to determine whether it is the first boot. If this is the first time, a boot page appears first.
2. Remember user information
Remember the password. png
userdefaults. Standard. Set(True, Forkey: "ishomepermissiongranted")
userdefaults. Standard. Synchronize()
Let ishomepermissiongranted = userdefaults. Standard. Value(forkey: "ishomepermissiongranted") as! Bool;
Print("final ishomepermissiongranted:" + (ishomepermissiongranted = = true ?) "true" : " false"))
[MAC OS] Userdefaults