iOS app for Settings.bundle

Source: Internet
Author: User

Settings.bundle

Settings.bundle supports six configuration items, namely: Title,multivalue,group,slider,toggleswitch,textfield.

Title

Type: The configuration types, default is title
Title: The title of the configuration item display
Identifier: identifier of the configuration item that is used to obtain the configuration contents of the configuration item
Default value: Configuration item Defaults

multivalueType: Configuration type, default multi Value

Title: The caption that the configuration item displays
Identifier: A configuration item identifier that gets the configuration contents of a configuration item
Default: Configure item defaults
Titles: An array of titles displayed
Value: An array of values displayed, corresponding to the titles one by one


Group

Type,title Ibid.

TextField text Field is Secure: whether ciphertext is displayed
KeyBoard Type: Keyboard type
Autocapitalization Stylele: Automatic capitalization
AutoCorrection Style: Automatically corrects spelling

Toggleswitch Slider

Minimum Value: Minimum value
Maximun value: Maximum
Min value image Filename: Minimum value end picture
Max value Image Filename: Max end picture

How to Set

1.New File->settings.bundle

The directory on the right will see:

Add the above-mentioned configuration items to the Root.plist:

Once configured, run the project, then click on the app in the settings, the effect is as follows:

Get configuration information in the program

Getting the configuration information is actually very simple, directly on the code:

Get settingsbundle information    nsuserdefaults *userdefaults = [Nsuserdefaults standarduserdefaults];        NSLog (@ "%@", [Userdefaults objectforkey:@ "title_perference"]);    NSLog (@ "%@", [Userdefaults objectforkey:@ "sex_perference"]);    NSLog (@ "%@", [Userdefaults objectforkey:@ "name_preference"]);    NSLog (@ "%@", [Userdefaults objectforkey:@ "enabled_preference"]);    NSLog (@ "%@", [Userdefaults objectforkey:@ "slider_preference"]);

Here's one thing to note:
If you run the app and get information directly from the code above, you'll get null because:
Root.plist is actually just a static file to display in the settings, and it will only be added to the nsuserdefaults if you modify it. After you modify the configuration, the nsuserdefaults has a higher priority than the Root.plist file.

iOS app for Settings.bundle

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.