Re: NSMutableString question
Re: NSMutableString question
- Subject: Re: NSMutableString question
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 16 Sep 2008 18:58:45 -0700
On Sep 16, 2008, at 6:29 PM, Jason Coco wrote:
Is it actually retained by the pool, or does the pool just delay
the final release?
It doesn't really matter how it's implemented... either way, you
shouldn't release it unless you own it (i.e., you've retained it
yourself or gotten it from one of the "ownership" methods such as
copy, alloc, etc.).
Actually, it does matter.
In particular, -autorelease is just "-release when the containing pool
is -drain'ed".
It is a pure balancing act.
Thus, you can validly do (silly, though it is):
[[[[a retain] retain] autorelease] autorelease];
And you'll end up having effectively done nothing. But, if you were
to look, your object would receive -release twice from the autorelease
pool.
It matters in that you shouldn't think about it. One of -release or -
autorelease MUST balance every -retain (or -retain implying creation
method). Outside of performance issues, it really doesn't matter which.
And, no, -autorelease does not contribute to thread safety. Not at
all.
b.bum
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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