How do I launch my settings bundle from my application?

12,087

Solution 1

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.

Update

The link has expired. This is a similar document on Settings bundles.

Solution 2

For iOs5 you can open settings directly:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

Solution 3

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.

Solution 4

I'm not aware of any way to launch Settings.app from your app. However, why not integrate the settings right in your app? You can use InAppSettingsKit to do that very easily.

Solution 5

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.

Share:
12,087
Lounges
Author by

Lounges

I build computer programs...

Updated on June 09, 2022

Comments

  • Lounges
    Lounges almost 2 years

    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?

  • bbrown
    bbrown almost 15 years
    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.
  • prashant
    prashant about 13 years
    I wouldn't be surprised if, as with location, there's a built-in OS prompt the first time an app tries to use push.