Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I recreate a "settings application"-like tableview inside my application?

I want to add a view to my application that allows the user to change several (many) settings. It should look like the built in "Settings Application" (see here) but it has to be within my app itself. At the moment I just have a tableview and I manually add different cell objects (corresponding to switches, sliders, etc). Is there a smarter of doing that? I have the feeling that I'm reinventing the wheel.

like image 302
hanno Avatar asked Jul 23 '09 02:07

hanno


1 Answers

This is an old question by internet standards, but I've found an amazing way to do this that requires very little effort. I was pulling my hair out trying to build a 2nd table view in another nib before i found these guys: InAppSettingsKit

Basically they've got all the views and the backend stuff done, all you do is add the files to your project and implement a few delegate methods in the class you're calling the settings page from (along with a button in your UI to open the settings panel, etc), and it takes care of the NSUserDefaults stuff. The UI and the settings values and keys are all generated from the same Settings.bundle used for the real settings app, which means your settings can be altered by the user in both places, in the app AND in the settings app. I found this much easier than messing with the delegate methods for a custom table view, and now i don't actually have to choose between Settings.app and something in-app because it does both.

All that's left is to pull the values you need for each settings key later on in your app when you need them, with [[NSUserDefaults standardUserDefaults] objectForKey:@"key"].

like image 168
steveatinfincia Avatar answered Nov 06 '22 20:11

steveatinfincia