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