views:

3733

answers:

5

I am working on adding in a settings bundle for my application as a cheap way of getting a GUI on my preferences. Is it possible to launch this from a button in my application or will my users always have to access it manually via the built in settings application?

+3  A: 

They may have to go to the settings application, depending on how you do it.

See this document, the Applications Preferences section. Here's the relevant section from the introduction:

Adding your application preferences to the Settings application is most appropriate for productivity-style applications and in situations where you have preference values that are typically configured once and then rarely changed. For example, the Mail application uses these preferences to store the user’s account information and message-checking settings. Because the Settings application has support for displaying preferences hierarchically, manipulating your preferences from the Settings application is also more appropriate when you have a large number of preferences. Providing the same set of preferences in your application might require too many screens and might cause confusion for the user.

When your application has only a few options or has options that the user might want to change regularly, you should think carefully about whether the Settings application is the right place for them. For instance, utility applications provide custom configuration options on the back of their main view. A special control on the view flips it over to display the options and another control flips the view back. For simple applications, this type of behavior provides immediate access to the application’s options and is much more convenient for the user than going to Settings.

Michael Sharek
+1  A: 

No, you can't--they'll have to exit your app and launch settings. It's a pain, and as stated above, a design decision you'll have to make.

drewh
A: 

I read this documentation too - but I'm confused: Say I do indeed have a small utility unsuited to the full system Settings treatment, how do I persist my settings? Can I still use the same NSUserDefaults code? (in Accessing Your Preferences from the same doc as above) Is there some other simple way to store application preferences in a resource file? (I'm talking about one or two booleans and float backed by a slider - no need for database storage here)

Rhubarb
+1  A: 

Answered my own question: You can indeed use the NSUserDefaults for saving your own applications preferences without having to integrate with the system settings.

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).

Note that I found this information from two sources.

  1. 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.

  2. 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)

Here are the methods in LevelAppDelegate.m that load the preference when the application starts, and saves it when it terminates:

// 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];
}

I guess, however, that the proper answer to the original question is:

  1. 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 return to your app from the Settings app, which would defeat the purpose).

  2. 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

In either case you can use the NSUserDefaults for the actual persistence.

Rhubarb
I asked an iPhone engineer about this at one of the tech talks and he said that you can't do that. He suggested I file a bug so that Apple can determine whether this is a popular request.
bbrown
A: 

I just saw the Aka-aki app take me directly to the Settings app's push notification screen. It did this the first time I launched it. So it must be possible. :)

Vikram Kriplaney