Setting Bundle for Your App


Hello Friends, in this tutorial we are going to learn about how we can implement Setting Bundle in our project and how we can use it.

iOS, Foundation framework provides the low level mechanism to store preference data. Using Setting Bundle you can configure application level settings. Setting Bundle’s Data is managed by the UserDefault.

Before creating the project let’s discuss the Preference Item and its properties.

1) Group: The group type is for organizing groups of preferences on a single page. The group type does not represent a configurable preference. It simply contains a title string that is displayed immediately before one or more configurable preferences.

a) Type: This property specifies the type of the preference. E.g TextField, Title, Toggle Switch, Slider etc
b) Title: This property is used to set the title of the preference.

These two properties are common for all the preference item.


2) Title: The title type displays a read-only string value. You can use this type to display read-only preference values.

a) Default Value: This property is used to set the default value. E.g Build Version
b) Identifier: This unique identifier is used to save and retrieve the preference value.


3) TextField: The text field type displays a title (optional) and an editable text field. It is used to take a input from the User.
The key for this type is PSTextFieldSpecifier.

a) Identifier: This unique identifier is used to save and retrive the preference value.
b) TextField Is Secure: This property is used to enter the secure text e.g Password. It has two values: 1. Yes, 2. No
c) KeyboardType: This property is used to set the keyboard type e.g URL, Email Address, Number Pad etc.
d) Auto Capitalization: This property is used to set the capitalization. E.g Sentence, Word, All Character

4) Toggle Switch: The toggle switch is an ON/OFF type button. One can use this to configure a preference where one of two values is required.

a) Default Value: Used to set the default toggle as an ON or OFF. It has two values “YES” and “NO”
b) Value for OFF: Used to set the toggle OFF value
c) Value for ON: Used to set the toggle ON value

5) Multi Value: The multi value type lets the user select one value from a list of values. You can use this type for a preference that supports a set of contradictory values. The values can be of any type.

a) Titles: This property is used to set the title of the Multi items.
b) Values: This property is used to set the value for the title.

6) Slider: The slider type displays a slider control. You can use this type for a preference that represents a range of values. The value for this type is a real number whose minimum and maximum value you specify.

a) Minimum Value: Used to set the Minimum value of the Slider.
b) Maximum Value: Used to set the Maximum value of the Slider.

How to Implement:

1) Configure new project in XCode
2) Press cmd + N
3) Select the setting bundle from the Resource



Now we are ready to start the implementation. We are going to take an Input from the user, Reset the app data and display the Build version and Number.


Make a class which handles the Setting Bundle Data. In the below code, I have implemented the functionality to Reset the Application data and Sets the Build Version and Number.

I have Called this Function from the AppDelegate.

When app becomes Active it will check all time Setting Preference.

How to fetch the data from the Setting Bundle?

To Fetch the User Default data we have to add the Observer and register the UserDefault in our code which notifies that something has been changed in the User Default.

Call addNotificationObserver() and registerSettingsBundle() in ViewDidLoad.


Shivam Shukla iOS Developer

I am an iOS developer at Yudiz Solutions Pvt. Ltd. - a leading iPhone App development company. I believe in finding better and optimistic solution to every problem and outdoing my own work. I am completely amused and obsessed to the iOS world. My goal is to keep learning and keep growing as a developer as there is no end to being better.

Comments are closed.