Re: Avoiding mutual retain cycles
Re: Avoiding mutual retain cycles
- Subject: Re: Avoiding mutual retain cycles
- From: Ken Thomases <email@hidden>
- Date: Mon, 21 Jul 2008 14:28:47 -0500
On Jul 21, 2008, at 1:50 PM, Markus Spoettl wrote:
By changing the reference from B to A to a weak reference which
doesn't retain and release A, the problem goes away. However,
generally speaking this is dangerous road to go (and against
memory management guidelines)
Actually, it is not against the guidelines, it is in keeping with them.
See here: http://developer.apple.com/documentation/Cocoa/Conceptual/
MemoryMgmt/Concepts/ObjectOwnership.html#//apple_ref/doc/uid/
20000043-1000698
That explicitly discusses retain cycles and the use of weak
references to break them.
For instance, how are delegates implemented in AppKit, are they
retained?
There are not retained by virtue of being assigned as a delegate.
They are retained by whatever code made the decision to assign them
as the delegate. If that code later decides to release the object,
it must also unset it as a delegate first.
Cheers,
Ken
_______________________________________________
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