Re: Protecting singleton objects from releasing
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.