• 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: Protecting singleton objects from releasing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Protecting singleton objects from releasing


  • Subject: Re: Protecting singleton objects from releasing
  • From: Jim Correia <email@hidden>
  • Date: Mon, 17 Feb 2003 19:00:30 -0500

On Monday, February 17, 2003, at 06:49 PM, publiclook wrote:

..in the singleton's class, which saves the overhead of looking up the external refcounts, etc.
Find, but is the performance of releasing soemething that should not be released a high concern ?

Who says a singleton should not be released?

Certainly it is valid (but unnecessary since we know the source is a singleton) to write

NSWorkspace *ws = [NSWorkspace sharedWorkspace];

[ws retain];
...
[ws release];

You main also desire to put singletons into an array, which will cause a retain/release on them. It is just in error to make the final release (which will cause deallocation) since you didn't own the singleton instance.

Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Protecting singleton objects from releasing (From: publiclook <email@hidden>)

  • Prev by Date: Re: Correctly setting icons for the Finder
  • Next by Date: Re: Restricting an NSSplitView when Resizing a Window
  • Previous by thread: Re: Protecting singleton objects from releasing
  • Next by thread: Re: Protecting singleton objects from releasing
  • Index(es):
    • Date
    • Thread