Am 21.07.2008 um 22:02 Uhr schrieb Markus Spoettl:

For example NSCollectionView, NSCollectionViewItem and its view. One may or may not suspect the NSCollectionViewItem owns the corresponding view. It may as well not own it and instead the NSCollectionView owns both.

I don't know why you'd think the collection view might own the item's view. You set the view for the view item, so the hierarchy seems to be quite clear. (The collection view *might* retain the view too. That's an implementation detail.)

Of course once you run into a retain cycle problem with this and no NSCollectionViewItem ever gets released because of it (like I did) you quickly learn why and who owns the view.

How would you get a retain cycle here? You just hold on to the collection view. Everything else should not be your responsibility.

I have to point out that I did not actually use those classes yet. (Instead I built something similar myself for 10.4. compatibility.) So I might be wrong here; I'd be surprised though.

The point is, unless this is documented explicitly the ownership relations are not clear all the time.

If you set something, it's usually retained. Exceptions from this norm should certainly be documented - like it is with delegates.


Andreas
_______________________________________________

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