Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answered my own question: You can indeed use the NSUserDefaults for saving your own applications preferences without having to integrate with the system settings.</p> <p>For example, my app is a Utility app with a small UI for a couple of settings on the FlipSide (the view the user gets to when pressing the "i" button).</p> <p>Note that I found this information from two sources.</p> <ol> <li><p>In a great series of reports from iPhone BootCamp, Scott Leberknight mentions in passing that he was taught that an applications user-defaults may or may not integrate in the settings app.</p></li> <li><p>The Sample code from the iphone official developer page for the BubbleLevel uses preferences for storing the calibration of the level (which is set on the flipside view)</p></li> </ol> <p>Here are the methods in LevelAppDelegate.m that load the preference when the application starts, and saves it when it terminates:</p> <pre><code>// Invoked after the application has been launched and initialized but before it has received its first event. - (void)applicationDidFinishLaunching:(UIApplication *)application { // Set up the level view controller levelViewController = [[LevelViewController alloc] init]; [window addSubview:levelViewController.view]; // Restore calibration for device float restoredOffset = [[NSUserDefaults standardUserDefaults] floatForKey:BubbleLevelCalibrationOffsetKey]; levelViewController.calibrationOffset = restoredOffset; } // Invoked immediately before the application terminates. - (void)applicationWillTerminate:(UIApplication *)application { float calibrationOffset = levelViewController.calibrationOffset; NSNumber *offset = [NSNumber numberWithFloat:calibrationOffset]; [[NSUserDefaults standardUserDefaults] setObject:offset forKey:BubbleLevelCalibrationOffsetKey]; } </code></pre> <p>I guess, however, that the proper answer to the original question is:</p> <ol> <li><p>No - you can't launch the settings UI from your own app (I haven't seen any way to do this - could be wrong I guess - but I'm pretty sure that even if you could launch Settings from your app, say the way a URL can be used to launch Safari - you wouldn't be able to <em>return</em> to your app from the Settings app, which would defeat the purpose).</p></li> <li><p>For preference-level persistence (as opposed to app data persisted in documents, database or cache) you have 2 choices i) use the system Settings app for your editing ii) create your own controls in your app</p></li> </ol> <p>In either case you can use the NSUserDefaults for the actual persistence.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload