- Part 1 - Creating a settings bundle which will show up in settings.
In this tutorial, I will show you how to create Application Preferences which will show up in Settings. This is how the Application Preferences will look like
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/FinalApp.jpg)
Select your project file in XCode (left side, in the file explorer) and Click File -> New File -> Click on Settings -> Select Settings Bundle and click Next. Give it a name and click on Finish.
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/Settings.jpg)
Click on Root.plist -> Expand Preference Specifiers. It is under Preference Specifiers, that all of our preferences will go. Some of them are already created for us. For the sake of this tutorial, I will delete all of them and create new ones from scratch.
Every field that shows up in Preferences is created by creating a new Item. This Item always has a Type and a Title.
Possible values for Type are
- PSTextFieldSpecifier
- PSTitleValueSpecifier
- PSToggleSwitchSpecifier
- PSSliderSpecifier
- PSMultiValueSpecifier
- PSGroupSpecifier
- PSChildPaneSpecifier
PSTextFieldSpecifier
Select "PreferenceSpecifiers" and click on the icon that shows up at the end. As shown in the image below. A random item number is shown in the image because I have deleted all of the items.
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/Clip1.jpg)
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/Clip2.jpg)
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/Item1.jpg)
Key: IsSecure
Type: Boolean
Value: YES/NO
Key: KeyboardType
Type: String
Value: Value must contain one of the following strings. Alphabet, NumbersAndPunctuation, NumberPad, URL and EmailAddress.
Key: AutocapitalizationType
Type: String
Value: Value must contain one of the following strings. None, Sentences, Words, AllCharacters. Default value is None.
Key: AutoCorrectionType
Type: String
Value: Value must contain one of the following strings. Default, No, Yes. Default value is Default.
PSTitleValueSpecifier
Key: Type (required)
Type: String
Value: PSTitleValueSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: Key (required)
Type: String
Value: Your string value.
Key: DefaultValue (required)
Type: String
Value: Your string value.
Key: Values
Type: Array
Value: Key-Value entry
Key: Titles
Type: Array
Value: Key-Value entry
PSToggleSwitchSpecifier
Key: Type (required)
Type: String
Value: PSToogleSwitchSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: Key (required)
Type: String
Value: Your string value.
Key: DefaultValue (required)
Type: String
Value: Your string value.
Key: TrueValue
Type: Boolean
Value: YES
Key: FalseValue
Type: Boolean
Value: NO
Key: Type (required)
Type: String
Value: PSSliderSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: Key (required)
Type: String
Value: Your string value.
Key: DefaultValue (required)
Type: String
Value: Your string value.
Key: MinimumValue (required)
Type: Number
Value: Minimum number value here
Key: MaximumValue (required)
Type: Number
Value: Maximum number value here
Key: MinimumValueImage
Type: String
Value: Image (21*21)
Key: MaximumValueImage
Type: String
Value: Image (21*21)
Key: Type (required)
Type: String
Value: PSMultiValueSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: Key (required)
Type: String
Value: Your string value.
Key: DefaultValue (required)
Type: String
Value: Your string value.
Key: Values
Type: Array
Value: Key-Value entry.
Key: Titles
Type: Array
Value: Key-Value entry.
Key: Type (required)
Type: String
Value: PSGroupSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: Type (Required)
Type: String
Value: PSChildPaneSpecifier
Key: Title (required)
Type: String
Value: Your string value.
Key: File
Type: String
Value: The name of plist file, without the extension.
We need some way to read that data and display it on the screen. We do this with the help of the following code
NSString *readOnlyValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"readOnly_key"];
NSString *sliderValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"slider_key"];
NSString *colorValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"colors_key"];
NSString *toogleValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"toogle_key"];
![](http://sites.google.com/site/iphonesdktutorials/images/appprefs/FinalView.jpg)
In this tutorial, I have created a new view and a view controller. It is in that view I display all the data from the preferences.
You can download the source code here.
Please leave me your comments and let me know know what are your thoughts. Your support is always appreciated.
Source: http://www.iphonesdkarticles.com/2008/08/application-preferences.html