Re: -init never gets sent
Re: -init never gets sent
- Subject: Re: -init never gets sent
- From: Greg Guerin <email@hidden>
- Date: Thu, 28 May 2009 18:04:49 -0700
Erg Consultant wrote:
Oddly, the object returned is non-nil.
I should mention that the pointer being returned is a hack global
declared at the top of the file like this:
static Registry *gReg = nil;
but that shouldn't matter.
Post your code for alloc and -init.
Your question can only be answered by seeing the actual code.
Without actual code, everyone is just guessing.
And I've checked that that global is never set to nil or created
twice anywhere else in the code.
If your intention is to always return a singleton Registry, you need
to follow the pattern for "Creating a Singleton Instance" in the
Cocoa-Fundamentals docs.
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/
TP40002974-CH4-SW32
If it is not your intention to always return a singleton Registry,
then returning "a hack global" is probably doing it wrong.
-- GG
_______________________________________________
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