Friday, July 31, 2015

iOS Settings Bundle - Registering default values

By default, iOS Settings bundle does not register the default values from the preferences. In order to make sure the default values are present, application needs to use the registerDefaults method. This can be either done one by one key and value like below or using the bundle.plist reading and getting the key and registering it. 

// Set the application defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"YES"
                                                        forKey:@"enableRotation"];
[defaults registerDefaults:appDefaults];

[defaults synchronize];

references:
http://useyourloaf.com/blog/2010/05/18/adding-a-settings-bundle-to-an-iphone-app.html

No comments:

Post a Comment