• 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: -init never gets sent
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Performance, Efficiency - Coding practice
  • Next by Date: Re: Performance, Efficiency - Coding practice
  • Previous by thread: Re: -init never gets sent
  • Next by thread: Performance, Efficiency - Coding practice
  • Index(es):
    • Date
    • Thread