Settings Bundle

As we’ve seen previously, NSUserDefaults is used to store preference data in iOS apps. There are then two options for displaying these preferences: directly inside the app and as a section in the Settings app.

Where you display preferences is up to you, and how you expect your users to interact with preferences. Usually, you’d want preferences that are accessed frequently inside the app. When displaying preferences inside the app, it’s up to you to decide how and where to display them.

However, a specific format must be followed to display the preferences in the Settings app. This is done using a Settings bundle, a collection of files describing the structure and presentation style of the preferences.

You can create a Settings bundle in Xcode using the New File menu.


This will generate two files in the bundle. The one holding all the configuration options is Root.plist. .plist stands for preference list, and it’s just an XML file.

Preferences items are set by adding entries to the list. Each entry has an identifier and a type, and a few extra options depending on the type. The file generated by Xcode is prepopulated with 4 entries: a Group, a Text Field, a Toggle Switch, and a Slider. You can see these by running the app on a device or the simulator, and then opening the Settings app.

The identifier is used to access the value of the preference in the app.

To add a preference, you simply add an entry to this list. There are many types of preference items.

  1. Group creates a new group of items. All items below this one will be part of the group, until the next Group item.
    • Title
  1. Text Field displays an editable text field, with an optional title.
    • Title – The text field name (optional).
    • Autocapitalization Style – Options to capitalize words, sentences, or all characters.
    • Autocorrection Style – Whether or not to autocorrect the input text.
    • Keyboard Type – The type of keyboard to display when editing (Email Address, Number Pad, etc.)
    • Text Field Is Secure – Replaces typed characters by (useful for passwords).
    • Default Value
  2. Toggle Switch displays an ON/OFF button.
    • Title
    • Default ValueYES or NO.
  3. Slider displays a slider, with customizable range.
    • Minimum Value – A number.
    • Maximum Value – A number.
    • Default Value – A number.
  4. Multi Value pushes the view to display a set of options to choose from.
    • Title
    • Titles and Values – Arrays holding the titles and values for each option. Both arrays should hold the same number of elements in matching order.
    • Default Value
  1. Title displays a read-only label.
    • Title
    • Default Value
  1. Child Pane displays a link to another .plist file, which can be used to display more options.
    • Title
    • Filename – The name of the linked .plist file.

Comments are closed.