Le 21 juil. 08 à 20:50, Markus Spoettl a écrit :

[...]

I'm wondering if there is a general rule or mechanism that suggests what to do in such a case. For instance, how are delegates implemented in AppKit, are they retained? If so, when are they released. It can't be in -dealloc, otherwise everything would lock itself out of deallocation?

Thoughts?

In the general case, there is no rule or mechanism to deal with retain cycles other than implementing something equivalent to a garbage collector. In some situations, however, the specific semantics and life-cycle of the objects you are dealing with allow implementing more simpler, ad hoc solutions (e.g., ownership management in the view hierarchy). Still, this requires notable housekeeping efforts and is often error prone. If you are in a situation where you can make use of Cocoa's garbage collector, you should go for it. It will free you from a bunch of low-level memory management tasks, including having to care about cyclic references.

Philippe Mougin
http://www.fscript.org
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to