Re: Autorelease Question
Re: Autorelease Question
- Subject: Re: Autorelease Question
- From: Sherm Pendley <email@hidden>
- Date: Thu, 20 Nov 2008 16:33:52 -0500
On Nov 20, 2008, at 4:04 PM, Adam Leonard wrote:
Now, I agree that it is mostly paranoia, but it is simply incorrect
to say that any object you send autorelease to, or get through a
method "whose name [DOES NOT] begins with "alloc" or "new" or
contains "copy"" will be sent release in the next run loop.
Actually, it *is* correct to say that any object to which you send -
autorelease will definitely will be sent a -release message the next
time around the run loop. What is incorrect is to assume that it will
necessarily be deallocated as a result of that -release message.
Thus, I sometimes see code that declares an instance variable
"workspace," assigns it to [NSWorkspace sharedWorkspace] in an init
method, then just uses it wherever, never bothering to retain it or
anything.
While I think that's a pretty stupid way to save a little bit of
typing
... especially given that there's an existing global variable NSApp
for precisely that purpose. :-)
sherm--
_______________________________________________
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