Re: Retain, then autorelease and then release does what?
Re: Retain, then autorelease and then release does what?
- Subject: Re: Retain, then autorelease and then release does what?
- From: Nicholas Riley <email@hidden>
- Date: Sat, 4 May 2002 01:48:25 -0500
- Mail-followup-to: Joel Rosenblum <email@hidden>, email@hidden
On Sat, May 04, 2002 at 02:39:52AM -0400, Joel Rosenblum wrote:
>
This seems odd. It would make sense to retain it, then autorelease it at
>
the end of the method, but if you retain and autorelease it at the same
>
time, isn't that having zero net effect, thus allowing the subsequent
>
release to release the object as it would without this code?
This is exactly what convenience constructors and most accessors do.
Instead of relying on the recipient to release the object manually,
they just autorelease it, so the caller can use the object and doesn't
have to worry about it thereafter (unless they're calling the
autoreleasing method in a loop, in which case they need to do some
manual pool management to avoid creating lots of garbage).
>
Also, I'd like a bit of clarification on one point: if I have a property
>
of a class which the class retains, when the class is released, will all
>
of its objects automatically be released as well, or must I explicitly
>
release each of them at that time?
Property? Huh? The only language I've seen that terminology is in
AppleScript.
You should really read a tutorial on retain/release, there are several
on Stepwise.
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
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.