• 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: Is Apple's singleton sample code correct?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Apple's singleton sample code correct?


  • Subject: Re: Is Apple's singleton sample code correct?
  • From: mmalcolm crawford <email@hidden>
  • Date: Sat, 26 Nov 2005 09:58:04 -0800

On Nov 26, 2005, at 7:21 AM, David Gimeno Gost wrote:
<http://developer.apple.com/cgi-bin/search.pl?
q=singleton&site=default_collection>

I already did that search before starting this discussion and I haven't found anything there stating that a singleton should never be deallocated.


The reference states that the instance cannot be released, so this is a natural corollary.


Actually, I would consider it a bug if I found it because there is nothing in the singleton design pattern requiring it to never be destroyed and there are indeed reasons why you may want to actually be allowed to destroy it when appropriate.

and

On Nov 26, 2005, at 7:53 AM, David Gimeno Gost wrote:

But I don't want to prevent the singleton from being deallocated.
[...]
That the particular adaptation of the singleton pattern made in the Cocoa frameworks does not allow for their singletons to be deallocated does not change what I'm saying in any way. You may have all the variations of the pattern that you see fit your particular needs. But they are variations, they are not part of the pattern as it is widely known.

This appears to be the fundamental problem. You seem to want the pattern to work in a particular way. It doesn't. It's been working the way it has in Cocoa since before the Design Patterns book was published (see, for example, <http://www.channelu.com/NeXT/NeXTStep/ 3.3/nd/GeneralRef/02_ApplicationKit/Classes/NXColorPanel.htmld/ index.html> or, with a different implementation, <http:// www.channelu.com/NeXT/NeXTStep/3.3/nd/GeneralRef/02_ApplicationKit/ Classes/FontManager.htmld/index.html> -- the (c) date is given as 1995, but the implementation preceded that by a couple of years), and is well-known within this community. The simple fact of the matter is that you're not going to change this, nor is it going to be recognised as a bug...

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


References: 
 >Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shawn Erickson <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shawn Erickson <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)

  • Prev by Date: Re: Is Apple's singleton sample code correct?
  • Next by Date: CVS: Only the linking fails, but how do we overcome this?
  • Previous by thread: Re: Is Apple's singleton sample code correct?
  • Next by thread: Re: Is Apple's singleton sample code correct?
  • Index(es):
    • Date
    • Thread