1. Kare Morstol
  2. mySettings

Wiki

Clone wiki

mySettings / Installation

Installation

  1. Download the mySettings project:
    1. Using mercurial: hg clone https://bitbucket.org/karemorstol/mysettings/
    2. ... or you can use the download links at the top right corner of this page. Extract it to the appropriate folder (from now on referred to as the <mySettings folder>).
  2. Open the project that will be using mySettings.
  3. Select "Add to project" from the project menu.
  4. Locate "mySettings.xcodeproj" in <mySettings folder> and add it (make sure "copy items into destination groups folder" is not checked).
  5. Find "libmySettings.a" under the newly added "mySettings.xcodeproj" item, and drag it to the "Link Binary with Libraries" phase of the appropriate target.
  6. Double-click the target, click the plus button under "Direct Dependencies" and select the "mySettings"-library.
  7. Go to <mySettings folder>/Code/Classes/, and select "SettingsViewController.h" and "SettingsMetadataSource.h".
    1. Also select SettingsCell.h and/or SettingsCellProtocol.h if you're going to create your own custom table cells.
  8. Drag the files to your project in Xcode and drop them wherever XCode will let you. Again, make sure "copy items into destination groups folder" isn't checked and click add.
  9. Create your Root.plist configuration file and place it under "Resources". You can use the file from <mySettings folder>/Resources/ as a starting point.
  10. Drag the plist file to the "Copy Bundle Resources" - phase of the target.
  11. And start programming.

To show the settings view controller:

NSString *plist = [[NSBundle mainBundle] pathForResource:@"Root" ofType:@"plist"];
SettingsViewController *settingsviewcontroller = [[SettingsViewController alloc] initWithConfigFile:plist];
[navigationController pushViewController:settingsviewcontroller animated:YES];

Which will retrieve and store the settings in the standard user defaults object ([NSUserDefaults standardUserDefaults]). Or you can use any other object (provided it supports key-value coding):

SettingsViewController *settingsviewcontroller = [[SettingsViewController alloc] initWithConfigFile:plist andSettings:anyobject];

Updated