Re: What's up with this....
Re: What's up with this....
- Subject: Re: What's up with this....
- From: Jens Alfke <email@hidden>
- Date: Thu, 22 Mar 2012 09:57:57 -0700
On Mar 22, 2012, at 9:36 AM, Alexandra Beebe wrote:
>> I have a class and in the class I added a "+(void) initialize" that just does a NSLog that it was in the class initialize function. Now when I include the class in a xib/nib file it works as expected. My NSLog message shows up. When I then hook a binding up that uses the class, everything breaks! My log shows 2 (two) NSLog initialize messages! Is this the correct list? Is this a bug? Is this the correct behavior? Am I missing something?
Does the class have any subclasses? If so, its +initialize will be called again when each subclass is initialized … see the docs on the +initialize method for more details. You should generally structure the method like this:
@implementation Foo
+ (void) initialize {
if (self == [Foo class]) { // ignore calls when subclasses are initialized
NSLog(@“Initializing Foo”);
…
}
}
And FYI, the most appropriate list for this kind of question is cocoa-dev. The xcode-users list is for issues with the development tools themselves.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden