• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Retain, then autorelease and then release does what?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Retain, then autorelease and then release does what?
      • From: Ondra Cada <email@hidden>
References: 
 >Retain, then autorelease and then release does what? (From: Joel Rosenblum <email@hidden>)

  • Prev by Date: Retain, then autorelease and then release does what?
  • Next by Date: Accessing window in document applications
  • Previous by thread: Retain, then autorelease and then release does what?
  • Next by thread: Re: Retain, then autorelease and then release does what?
  • Index(es):
    • Date
    • Thread