Re: How to observe NSTreeController in a custom view?
Re: How to observe NSTreeController in a custom view?
- Subject: Re: How to observe NSTreeController in a custom view?
- From: Quincey Morris <email@hidden>
- Date: Fri, 5 Sep 2008 00:21:36 -0700
On Sep 4, 2008, at 23:10, Oleg Krupnov wrote:
In the samples I have seen, custom views observe linear arrays
(NSArrayControllers). When the observeValue:forKey: message is sent to
the custom view, it checks what happened to the array. Because the
change dictionary does not help in this case, the view has to maintain
a copy of the previous array, so that by comparing the old and new
arrays, the view can tell the difference. This by the way looks quite
lame, isn't there a better way?
In general, it's not necessary for the observer to keep a copy of the
old array. However, there's a longstanding bug in NSArrayController
that means it doesn't pass the correct change information, so the
sample code you're looking at might be working around this bug. It's
only lame because there's a lame bug.
However I am having a really hard time trying to figure out how an
NSTreeController would work in this case by analogy. The
NSTreeContoller is also bound to the view via its "arrangedObjects"
property, which is in the case of trees "a proxy root tree node
containing the receiver's sorted content objects". Am I supposed to
maintain a copy of this node to make comparisons and tell the change
difference, like with arrays? If this is the case, how am I supposed
to traverse this root node, isn't it opaque? I've noticed the
NSTreeNode class, but it doesn't look connected to anything in the
docs...
Also I wonder what "arranged" means in the case of trees. Are the
siblings nodes arranged in each "folder" separately, or there is some
kind of global sort?
It's not properly documented yet. See here:
http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSTreeController
_______________________________________________
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