Re: retain and autorelease
Re: retain and autorelease
- Subject: Re: retain and autorelease
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 14 Nov 2003 14:58:18 -0800
On Nov 14, 2003, at 2:03 PM, Clark Cox wrote:
On Nov 14, 2003, at 16:26, Ben Dougall wrote:
that's something i've never been sure on - the lifetime of an
unretained object like that. you say it'll probably hang round until
the end of the current method - what about if there's a method call
inbetween the above non retained convenience creation and the end of
the current method? even a simple presumably short/quick method call
like adding an object to an array for exmaple? that takes the thread
elsewhere, out of the current method. would it still be ok not to
retain do you think?
The lifetime of an autoreleased object has *nothing at all* to do with
the method scope. the object will stick around until the current
autorelease pool is destroyed, this happens automatically, each time
through the event loop. Of course, if you don't explicitly destroy the
current autorelease pool inside your method, then autoreleased objects
therein will indeed remain valid throughout the method.
This is true *if the object is returned to you autoreleased*. Ben
*appeared*, however, to be asking a slightly different question, which
is addressed here:
<
http://www.stepwise.com/Articles/Technical/2002-06-11.01.html/>
mmalc
_______________________________________________
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.