• 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 & release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: retain & release


  • Subject: Re: retain & release
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 18 Sep 2005 01:57:37 -0700

On Sep 17, 2005, at 3:19 PM, Boyd Collier wrote:
In trying to follow the (supposedly) simple rules of using retain and release, I wrote the following bit of code.

They are simple, and as the others have pointed out you just need to balance your own invocations of +alloc, -copy, and -retain methods. The important thing to remember about the rules is that they're not necessarily about memory management -- they're really about *object ownership*.


When you create an object (+alloc or -copy), you own it and need to clean it up (-release or -autorelease). If you get an object from elsewhere and need to keep it around, you take ownership of it (- retain) and relinquish ownership of it later (-release or -autorelease).

If you keep this in mind, it might make the applicability of the memory management rules in any particular situation clearer.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >retain & release (From: Boyd Collier <email@hidden>)

  • Prev by Date: Conditional inclusion of items in Interface Builder?
  • Next by Date: Re: NSImageView and CoreData entity creation
  • Previous by thread: Re: retain & release
  • Next by thread: Starting a Spotlight search
  • Index(es):
    • Date
    • Thread