Easy In App Settings
BAMSettings is a generic handler for presenting and changing settings from within your iPhone app. By adding two files to your app and pushing BAMSettings onto your navigation controller, you will have the full functionality of Apple’s Settings App from within your own app.
Why Use BAMSettings?
Okay, so you’ve carefully crafted a settings bundle for your iPhone app and you would like to give your users the ability to change settings from within your app, too. After writing several custom settings pages it has occurred to me that it would be useful to have a generic handler for this purpose. Since this is such a common occurrence, I’ve decided to release the code publicly so you use it in your apps for free.
Identical to iPhone Settings
Your existing settings bundle will be used to present an interface which is identical to the existing iPhone settings. It is fully localized and will use your strings files to present the settings in whatever language the user has selected on their phone. Your multi value fields, text fields, toggle switches, sliders and groups will be automatically populated in the same familiar way that your users have become accustomed to. In addition to the usual setting types, you can also use group footers, child panes, and title values which are less common and not in the default Xcode dropdown menus.
Even Better than iPhone Settings
While writing this, I couldn’t help but add a few small improvements: The keyboard can be dismissed by pressing the return key while there is no way to dismiss a keyboard on the iPhone settings app, BAMSettings can rotate to any orientation while the iPhone settings app only supports the portrait orientation, and in an effort to ease the debugging of your settings bundle, BAMSettings will display a table cell informing you if you use a setting type that is unknown rather than simply ignoring it. If you run across a setting type that Apple’s settings app handles but is unknown to BAMSettings, please let me know so I can update the code.
Use It for Free
I’m releasing BAMSettings publicly under the permissive Simplified BSD License (FreeBSD) to allow reuse by anyone who wants to use it. You can modify the code in any way that suits your project whether simply changing colors and fonts or even adding custom settings types. It was designed to be a great jumping off point for any in-app settings project. I would appreciate a credit and a link back to this site if you use it but it certainly is not required and I would enjoy hearing from anyone who uses this in their projects.
How to Use BAMSettings
The BAMSettings Demo post gives detailed instructions for adding BAMSettings to your project and includes a downloadable demo project.
I have chosen to leave BAMSettings sparsely commented. It is my belief that comments simply dilute the code (by decreasing the amount of actual code onscreen) when it contains thoughtful naming and is viewed by an experienced programmer. However, if others would find it useful, I would be willing to write a blog entry that explains precisely how the code within BAMSettings works.