Re: Why would +[initialize] be called twice?
Re: Why would +[initialize] be called twice?
- Subject: Re: Why would +[initialize] be called twice?
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 24 Aug 2009 08:09:42 -1000
On Aug 24, 2009, at 7:19 AM, Michael A. Crawford wrote:
Why would the class initializer be called more than once when my app
starts up? Is this expected behavior? In case you're wondering, it
is called twice.
+ (void)initialize
{
// Create the defaults dictionary, fill it with the standard
values,
// and register it.
NSMutableDictionary* defaultValues = [NSMutableDictionary
dictionary];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:CDFilterKey];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:CDNotifyUserOnAnalysisCompletionKey];
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:CDPlaylistReminderKey];
[[NSUserDefaults standardUserDefaults]
registerDefaults:defaultValues];
MCLog(@"Registered defaults: %@", defaultValues);
}
You got your answer.
However, I would suggest registering defaults in a different way.
Specifically, I have always pushed my registration defaults into a
property list that sits in the app bundle.
Then:
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues:
[NSDictionary dictionaryWithContentsOfFile: [[NSBundle mainBundle]
pathForResource: @"RegistrationDefaults" ofType: @"plist"]]];
b.bum
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden