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 (Cocoa-dev@lists.apple.com)

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