• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why would +[initialize] be called twice?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why would +[initialize] be called twice?


  • Subject: Re: Why would +[initialize] be called twice?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Mon, 24 Aug 2009 19:38:19 +0200


Le 24 août 2009 à 19:19, Michael A. Crawford a écrit :

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);
}

Just a question. Did you read the +initialize reference before posting ?

Especially this part:
“If a particular class does not implement initialize, the initialize method of its superclass is invoked twice, once for the superclass and once for the non-implementing subclass. If you want to make sure that your class performs class-specific initializations only once, implement initializeas in the following example: …”


_______________________________________________

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


References: 
 >Why would +[initialize] be called twice? (From: "Michael A. Crawford" <email@hidden>)

  • Prev by Date: Re: authorization services
  • Next by Date: Re: Why would +[initialize] be called twice?
  • Previous by thread: Re: Why would +[initialize] be called twice?
  • Next by thread: Re: Why would +[initialize] be called twice?
  • Index(es):
    • Date
    • Thread