3. PSMultiValueSpecifier
The PSMultiValueSpecifier is for selecting one of many alternative choices. Table 3
summarizes the PSMultiValueSpecifier’s settings. Note that you create
entries below the Values and Titles settings for each value and for each
title.
Table 3. PSMultiValueSpecifier SettingsKey | Purpose | Type | Valid Values | Required |
---|
Type | Specifies preference type. | String | PSMultiValueSpecifier | 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 | Values | Specifies an array of values. | Array | Array of Key-Value entries | Yes | Titles | Specifies titles for array of values. | Array | Array of Key-Value entries | Yes | Default Value | Specifies a default value for the preference. | Any | Any value from the Values array | Yes |
Return to MySettings in Xcode. Open the Root.plist in the editor. Create an Item 2 below PreferenceSpecifiers and ensure its type is Dictionary. Expand Item 2 and add six new child rows. Change the first child row to have Type for the key, String for the type, and PSMultiValueSpecifier for the value (Figure 7).
Change the next child row to have Title for the key, String for the type, and Colors for the value. Change the next child row to have DefaultValue for the key, String for the type, and blue for the value. Change the next child row to have Key for the key, String for the type, and keyTwo for the value. Change the next two child rows to have Titles and then Values for the key and Array for the type. Expand Titles and then add three child rows to it. Do the same for Values (see Figure 7).
Assign the three child Titles the values Red, Blue, and Orange. Assign
the three child Values the values red, blue, and orange. Click Run. Navigate to the Settings application, and the new setting appears (Figure 8).
4. PSToggleSwitchSpecifier
The
PSToggleSwitchSpecifier is for selecting a Boolean value. The toggle
switch displayed in the Settings application for this specifier is On or
Off. Table 4 summarizes the PSToggleSwitchSpecifier’s settings.
Table 4. PSToggleSwitchSpecifier SettingsKey | Purpose | Type | Valid Values | Required |
---|
Type | Specifies preference type. | String | PSToggleSwitchSpecifier | 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 | TrueValue | The value for on. | Any | Any scaler type, including Boolean, String, Number, or Data. Default is Boolean | No | FalseValue | The value for off. | Any | Any scaler type, including Boolean, String, Number, or Data. Default is Boolean | No | DefaultValue | Specifies a default value for the preference. | Any | String value from TrueValue or FalseValue | Yes |
Return
to Root.plist and add Item 3 below PreferenceSpecifiers (i.e.,
highlight Item 2 and click the plus sign on the right). Change the new
item’s type to Dictionary. Expand
Item 3 and add six new child rows. Change the first child row to have a
Type for key, String for type, and PSToggleSwitchSpecifier for value.
Change the second child row to have Title for key, String for type, and
Use Colors? for the value. Change the third child row to have Key for
key, String for type, and keyThree for value. Change the fourth child
row to have TrueValue for key, String for type, and YES for value.
Change the fifth child row to have FalseValue for key, String for type,
and NO for value. Finally, change the sixth child row to have
DefaultValue for key, String for type, and NO for value (Figure 9).
Click Run. Navigate to Settings, and the new value appears (Figure 10).
Note
Notice we keep stating to “save the .plist
file” as its own step. The reason for this is that Run does not
automatically save the .plist file.
|