Re: Double Initialize - is that how it should be?
Re: Double Initialize - is that how it should be?
- Subject: Re: Double Initialize - is that how it should be?
- From: Jim Correia <email@hidden>
- Date: Tue, 17 Mar 2009 10:17:31 -0400
On Mar 16, 2009, at 10:21 PM, Steve Cronin wrote:
I use an object in my application called 'appDelegate'; it's a
subclass of NSObject.
I instantiate this object in the main Nib file
This object has IBActions for the main menu and since it is -app
delegate it is a kind on central dispatcher.
My question is this:
The +initialize is run twice when the app loads:
2009-03-16 20:21:42.690 XYZ[6676:813] *[AppDelegate initialize]
2009-03-16 20:21:42.781 XYZ[6676:813] *[NSKVONotifying_AppDelegate
initialize]
Once for the object itself and then again as the instance in the
Nib. That's how I read this. Is that wrong?
The specific reason that you got +initialize twice has to do with an
implementation detail of automatic KVO.
There are also other reasons that you could get +initialize twice.
(For example, a subclass of yours doesn't implement initialize.)
This is discussed in the NSObject documentation, and the pattern to
use to avoid "double" initialization is given.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html#/
/apple_ref/occ/clm/NSObject/initialize
Jim
_______________________________________________
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