• 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
Retain, then autorelease and then release does what?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Retain, then autorelease and then release does what?


  • Subject: Retain, then autorelease and then release does what?
  • From: Joel Rosenblum <email@hidden>
  • Date: Sat, 4 May 2002 02:39:52 -0400

I read on Apple's site that "If you need to use an object after disposing of its owner or rendering it invalid by some other means, you can retain and autorelease it before sending the message that would invalidate it."

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?

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?
_______________________________________________
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: Nathan Zamecnik <email@hidden>
    • Re: Retain, then autorelease and then release does what?
      • From: Ondra Cada <email@hidden>
    • Re: Retain, then autorelease and then release does what?
      • From: Nathan Day <email@hidden>
    • Re: Retain, then autorelease and then release does what?
      • From: Nicholas Riley <email@hidden>
  • Prev by Date: Re: Returns from a sheet
  • Next by Date: Re: Retain, then autorelease and then release does what?
  • Previous by thread: Re: Leaks When Running MultiThreaded (Even w/ AutoRelease Pool)
  • Next by thread: Re: Retain, then autorelease and then release does what?
  • Index(es):
    • Date
    • Thread