• 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: Dirk Stegemann <email@hidden>
  • Date: Sun, 4 Dec 2005 05:58:02 +0200

Hi,

Am 04.12.2005 um 05:08 schrieb Andreas Mayer:

Am 04.12.2005 um 03:06 Uhr schrieb Dirk Stegemann:

What is the sound and important technical reason for overriding the reference counting methods in the case of a singleton ?

To prevent it's accidental deallocation, when no other objects happen to be retaining it.
(...)

This is a general problem which applies to all kinds of objects, be they singletons or non-singeltons,
(...)

Following the argumentation of the advocators of the "Overwrite the -dealloc method to do nothing" approach, this problem doesn't apply to the singleton objects,

Provided that there is no memory management error in the application, the singleton will not be deallocated, since it basically retains itself. The normal Cocoa memory management rules DO apply.

No overwrite of dealloc needed.

I thought that somebody stated some time ago -- within this thread -- that the singleton should be "*guaranteed* to exist during entire life time of the application"; then IMHO the implementation should even be bullet-proof against over-releasing/-deallocating.

But I cannot find this statement now, neither is it said in that piece of documentation which caused the OP's request in the first place.

So I agree now.

Best regards,
Dirk Stegemann



_______________________________________________
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
  • Follow-Ups:
    • Re: Is Apple's singleton sample code correct?
      • From: Todd Blanchard <email@hidden>
References: 
 >RE: Is Apple's singleton sample code correct? (From: Jeff Laing <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: mmalcolm crawford <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Dietmar Planitzer <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shaun Wexler <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Dietmar Planitzer <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shaun Wexler <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Dietmar Planitzer <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Dirk Stegemann <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Searching for an entity in a relationship (CoreData)?
  • Next by Date: Is it possible to control "returnCode" value when using Custom Sheet?
  • 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