[MAC OS] Userdefaults

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.