I have an AppDelegate class with +(void)initialize
method that I use to register some defaults. Here's the code that I use:
+ (void)initialize {
NSDictionary *defaults = [NSDictionary dictionaryWithObjectsAndKeys:@"NO", @"fooKey", @"YES", @"barKey", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
I also created Preferences.xib which holds couple of checkboxes (NSButton
) that display status of preferences. They are bound to NSUserDefaultsController
with same keys (fooKey and barKey in this case). Each time I launch an app and change the "defaults" they are restored on next app launch.
Is there a way to register "default defaults" without overwriting already existing values? Maybe each time I build and launch an app its preferences file is being recreated? Maybe I should unbind checkboxes from NSUserDefaultsController
and maintain the values of keys myself with some custom code in preferences window controller?
I'd like to hear your implementation of choice for maintaining user defaults.
I'm using Mac OS X 10.6.2 and XCode 3.2.1