views:

164

answers:

1

If I'm using NSUserDefaults to store settings for my application, is there any way to make my app's settings "hidden" from being shown in the general Settings application on the iPhone? I know there are other tools out there such as mySettings, Keychain, etc, but I'm just wondering if there is a flag somewhere that says 'do not show my settings' in Settings, since I just want them to be edited through my own application.

+3  A: 

It depends mostly on how you think the settings will be used. If they will be accessed and changed frequently, then it may be a good idea to place them within the app, so they're easily accessible. However, if the settings are something the user may only change once throughout their usage of the app, and rarely change them, it may be a good idea to put them in a settings bundle out of the way.

Settings are only visible in Settings.app if you specifically put them into a settings bundle.

Jasarien
I think the key here is your final paragraph. You can use `NSUserDefaults` without having a Settings bundle in your app.
Stephen Darlington
"You can use NSUserDefaults without having a Settings bundle in your app." That is exactly what I'm looking for. Can you point me to any examples?
sw
Yes, correct. NSUserDefaults aren't directly linked to Settings.app and there is no solid dependency or link between the two. Anything stored in NSUserDefaults is persisted throughout the life of the App on the iPhone until the app is deleted or the app removes them. When the app is deleted anything in the NSUserDefaults goes with it.
Jasarien
NSUserDefault's interface is just like an NSDictionary, you can set objects for particular keys, providing they are plistable (NSStrings, NSArrays, etc. etc.) Eg. `[[NSUserDefaults standardDefaults] setObject:myObject forKey:@"MyKey"];` will store myObject in the User Defaults under the key MyKey. When you can read it back like this: `[[NSUserDefaults standardUserDefaults] objectForKey:@"MyKey"];`
Jasarien
Great. So basically if I just delete my settings bundle, my code should still work using the same old stringForKey, etc, as long as I make sure to set a default in my application launching, etc.
sw
It's also useful to know that anything stored in the user defaults is tied to your app's bundle ID, so it reduces the likelyhood that you'll hit a key conflict with another app, or prevent another app from reading your preferences.
Jasarien
Yes, if you settings are stored in NSUserDefaults there shouldn't be any tight coupling between it and your settings bundle. Removing it should be safe, and providing defaults on app launch if the values aren't set is a good idea.
Jasarien