Re: + initialize docs conflict?
Re: + initialize docs conflict?
- Subject: Re: + initialize docs conflict?
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 1 Feb 2005 11:07:52 -0800
On Feb 1, 2005, at 6:59 AM, Buck, Erik (Space Technology) wrote:
I believe the issue with a single +initialize implementation being
called multiple times is the following:
The run-time sends the +initialize message to each class once.
However, if the class does not implement the +initialize method, an
inherited implementation is called.
For example, NSControl is a subclass of NSView.
The runtime sends the +initialize message to NSView.
Then the runtime sends the +initialize message to NSControl.
To be candid I don't remember what the exact sequence is, but this
seems to fit with the standard "solution" I have always encountered:
@implementation MyClass
+ initialize
{
if (self == [MyClass class])
{
// initialize MyClass
}
}
// ...
This avoids the need to use the one shot static...
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden