1. Settings Field Types
You
add preferences to the settings bundle through Root.plist. The
different settings display differently in the Settings application.
Possible values for settings are PSTextFieldSpecifier,
PSTitleValueSpecifier, PSToggleSwitchSpecifier, PSMultiValueSpecifier,
PSGroupSpecifier, and PSChildPaneSpecifier. This section considers each
setting in turn.
PSGroupSpecifier
The PSGroupSpecifier groups settings into a group. If
you have many settings, consider using this specifier to group your
settings into logical groupings. Table 1 summarizes the PSGroupSpecifier’s settings.
Table 1. PSGroupSpecifier Settings
Key | Purpose | Type | Valid Values | Required |
---|
Type | Specifies preference type. | String | PSGroupSpecifier | Yes |
Title | Specifies the title displayed by Settings application. | String | Any string value | Yes |
PSTextFieldSpecifier
The PSTextFieldSpecifier is for a preference whose value is a string. Table 2 summarizes a PSTextFieldSpecifier’s settings.
Table 2. PSTextFieldSpecifier Settings
Key | Purpose | Type | Valid Values | Required |
---|
Type | Specifies preference type. | String | PSTextFieldSpecifier | Yes |
Title | Specifies the title displayed by the Settings application. | String | Any string value | Yes |
Key | Specifies the preference’s key used for storage and retrieval. | String | Any string value | Yes |
Default Value | Specifies a default value for the preference. | String | Any string value | No |
IsSecure | Specifies if preference should be treated as password. | Boolean | Yes or No | No |
KeyboardType | Specifies type of keyboard to display when tapped. | String | Alphabet, NumbersAndPunctuation, NumberPad, URL, EmailAddress: default is Alphabet | No |
AutoCapitalization Type | Specifies if autocapitalization should occur. | String | None, Sentences, Words, AllCharacters; default is None | No |
AutoCorrection Type | Specifies if spelling should be automatically corrected. | String | Default, Yes, No | Default |
Open MySettings in Xcode. Open Root.plist in the Editor window.
Expand PreferenceSpecifiers and delete Item 1, Item 2, and Item 3, leaving just Item 0.
Select
Item 0 and click the plus sign to its right. It adds a new row (Item
1). Note that this row is a child of PreferenceSpecifiers.
Select Item 1 and change its type to Dictionary.
Control-click
Item 1, expand it, and select Add Row. A new child row should be added.
Note that this row is a child of Item 1. Add two more new child rows;
ensure that they are children of Item 1. Change each row to match Figure 5.
Click Run. Navigate to Settings and MySettings settings. Click the text field, and your Simulator should match Figure 6.