Re: retain & release
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