I\'m adding a Settings.bundle file to my iOS application. It\'s very minimal with one or two settings. The plist file in the Settings.bundle specifies the defaults, to the S
Wanted to add this as a comment to Andy's answer, but Stack Overflow didn't let me (too long for a comment).
If you're using ObjC here's your version:
-(void)registerDefaults
{
NSString* pathString = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Settings.bundle"];
NSString* rootPath = [pathString stringByAppendingPathComponent:@"Root.plist"];
NSDictionary* settingsDict = [NSDictionary dictionaryWithContentsOfFile:rootPath];
NSArray* prefSpecifiers = settingsDict[@"PreferenceSpecifiers"] ;
NSMutableDictionary* defaults = [NSMutableDictionary dictionary];
for (NSDictionary* item in prefSpecifiers) {
NSString* theKey = item[@"Key"];
NSObject* defaultValue = item[@"DefaultValue"];
if (defaultValue && theKey) {
defaults[theKey] = defaultValue;
}
}
if (defaults.count > 0) {
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
}