Re: Avoiding mutual retain cycles
Re: Avoiding mutual retain cycles
- Subject: Re: Avoiding mutual retain cycles
- From: Andreas Mayer <email@hidden>
- Date: Mon, 21 Jul 2008 21:21:43 +0200
Am 21.07.2008 um 20:50 Uhr schrieb Markus Spoettl:
I'm wondering if there is a general rule or mechanism that suggests
what to do in such a case.
About retain cycles:
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectOwnership.html
"The solution to the problem of retain cycles is that the “parent”
object should retain its “children,” but that the children should not
retain their parents."
For instance, how are delegates implemented in AppKit, are they
retained?
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html
"Delegating objects do not (and should not) retain their delegates."
But there are still cases where it is unknown which of the objects
is going to be released first
Care to name one?
I generally do not find it difficult to decide which object needs to
own which. In case you can't decide, maybe neither should and you are
better off adding a third object that handles both.
Andreas_______________________________________________
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