The picture below is the page after clicking the Nail APP in the mobile phone Settings:

The above, you must be too familiar with, so how does it work? That’s right: Settings.bundle.

#Settings.Bundle

Settings.Bundle supports Title, MultiValue, Group, Slider, ToggleSwitch, and TextField.

##Title

Type: indicates the configuration Type. The Default Value is Title. Title: indicates the Title Identifier displayed for the configuration item

##MultiValue

Type: configuration Type, Default Multi Value Title: Title to be displayed Identifier: Identifier to obtain configuration content Default: Default Value Titles: array of Titles to be displayed Values: Displays an array of values that correspond to Titles

##Group

Type, Title;

##TextField

Text Field Is Secure: ciphertext display KeyBoard Type Autocorrection Style: automatically capitalization

##ToggleSwitch

##Slider

Minimum Value: Minimum Value Maximun Value: maximum Min Value Image Filename: Minimum Image Max Value Image Filename: maximum Image

# How to set

1.New File ->Settings.Bundle

In the directory on the right you will see:

Add the above configuration items to root.plist:

After the configuration, run the project, and then click app in the Settings, the effect is as follows:

Obtain the configuration information in the program is actually very simple, directly on the code:

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"]);
Copy the code

One caveat: if you run the application and get the information directly from the above code, you’ll get NULL; The reason: root.plist is really just a static file to display in Settings; It only adds to NSUserDefaults if you modify it. After configuration modification, NSUserDefaults takes precedence over root.plist files.

# the last

SettingsBundle is useful in enterprise applications where background access addresses need to be configured by the user.

Demo_Git address