• 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: Cocoa coding style (was Re: Did I reinvent the wheel?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa coding style (was Re: Did I reinvent the wheel?)


  • Subject: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Sat, 10 May 2008 20:42:40 -0700


On May 10, 2008, at 8:12 PM, Michael Ash wrote:

Even in this case, all you need to do is override -init to return the
shared object. Apple's sample code, showing overrides to -retain,
-release, and other such methods, just serves to hide bugs in the
calling code.

I'd agree with that; I think it's generally more useful to raise an exception on dealloc to catch the memory management errors. The sample code also uses @synchronized in +sharedInstance, which turns out to be surprisingly bad for performance if you happen to call +sharedInstance in a loop.


There was a very long thread on Apple's singleton example a few years ago:

http://www.cocoabuilder.com/archive/message/cocoa/2005/11/25/151080

I don't think the example changed significantly as a result, though.

--
adam

_______________________________________________

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


References: 
 >Did I reinvent the wheel? (From: Western Botanicals <email@hidden>)
 >Cocoa coding style (was Re: Did I reinvent the wheel?) (From: Chris Hanson <email@hidden>)
 >Re: Cocoa coding style (was Re: Did I reinvent the wheel?) (From: Michael Watson <email@hidden>)
 >Re: Cocoa coding style (was Re: Did I reinvent the wheel?) (From: Chris Hanson <email@hidden>)
 >Re: Cocoa coding style (was Re: Did I reinvent the wheel?) (From: Jim Correia <email@hidden>)
 >Re: Cocoa coding style (was Re: Did I reinvent the wheel?) (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
  • Next by Date: custom image unit not working when called from a Cocoa app
  • Previous by thread: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
  • Next by thread: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
  • Index(es):
    • Date
    • Thread