Lesson 23

Application Settings

Most applications that perform complex tasks will at some point need to allow users to customize the applications' operation to suit their specific needs. These customizable options are usually referred to as application preferences or application settings. iOS applications can either expose their preferences within Apple's Settings application, or provide a user interface within the application where the user can customize them appropriately.

To integrate your application's preferences with Apple's Settings application, your application must include a Settings.bundle file. A settings bundle file enables you to declare the preferences in your application as a property list, and the Settings application provides the user interface for editing those preferences.

Keep in mind that to access the Settings application your users will have to first exit your application if they were using it. You should always refresh settings data when the application is activated so that your application can learn about the changes made by the user via the settings app. In this lesson, you learn to create this file and use it to expose system preferences.

Adding a Settings Bundle

To add a Settings.bundle file to your application, right-click your application's group in the project navigator and select New File from the context menu. Select the Settings Bundle file type from the iOS Resource section of the dialog box (see Figure 23.1).

Figure 23.1

When the Settings ...

Get Swift iOS 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.