Re: Correct memory management in -awakeAfterUsingCoder: ?
Re: Correct memory management in -awakeAfterUsingCoder: ?
- Subject: Re: Correct memory management in -awakeAfterUsingCoder: ?
- From: Michael Ash <email@hidden>
- Date: Tue, 5 May 2009 11:13:22 -0400
On Tue, May 5, 2009 at 12:45 AM, Graham Cox <email@hidden> wrote:
> If I retain the object before returning it in -awakeAfterUsingCoder:, the
> problem goes away, but this appears to violate normal memory management
> rules, so it's not clear that this is the correct solution. The
> documentation doesn't explicitly say anything about this either.
Actually it fits them just fine, when you look at the rules like this:
- Within any pair of {}, the number of calls to alloc, copy, and
retain must match the number of calls to release and autorelease.
Generally there's an exception for init/dealloc methods, but if you
use accessor religiously then you don't even need that exception.
Following this rule (which is not from Apple's docs, but comes from
http://www.stepwise.com/Articles/Technical/2001-03-11.01.html), you
balance the release with a retain (or alloc or copy).
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden