On Jun 11, 2008, at 4:44 PM, Daniel Price wrote:

As a test, I have an NSTreeController and an NSOutlineView within the same nib of a CoreData application (Leopard). If I bind the columns of the outline view to the controller directly within IB, it works as expected. eg:

ShapeTC->arrangedObjects.name (where name is the attribute of the CoreData entity)

Now if I add an outlet (and accessor) in MyDocument to that same controller instance in the nib and try to access the exact same data via the keypath:

Application- >mainWindow.document.shapeTreeController.arrangedObjects.name

I get nothing in the view and this error in the log:

[<_NSControllerTreeProxy 0x1c73a0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key name.


I thought the whole shadow-object problem was fixed in Leopard?! Are these paths not equivalent and if so, why am I getting back this private object in the second case but not the first?

I'm not sure what you mean by shadow-object problem.
Just to explain something: NSArray and NSSet implement valueForKey to return an array (or set) of the results of doing valueForKey on each of their contained objects. You probably already know this.

NSTreeNode doesn't do this. There's an enhancement request for this tho. Feel free to pile on.

SO, [treeNode valueForKey:] doesn't do anything special right now.

In Leopard, [treeController arrangedObjects] returns a proxy object (the same way that NSArrayController does for its arrangedObjects method). The proxy object currently isn't a subclass of NSTreeNode. Feel free to pile on bugs for that one too.

BUT, the treeController's arrangedObjects proxy DOES respond to two NSTreeNode methods -
        - childNodes
        - descendantNodeForIndexPath

(I'm typing these from memory, so please check these with the .h)
Incidentally, I believe the documentation is wrong about this. The header is right.

NOW, you can iterate over the tree yourself, going from childNode to childNode getting valueForKeyPath@:"representedObject.name".





I've also tried using arrangedObjects.representedObject.name but I get the same error.

I need to figure this out because each of my documents maintains a tree controller (for the selection) but floating panel with an outlineview displays the contents of the current document. So there is only one outline view on screen. I used to do with with code and notifications and it worked but want to use bindings instead. Cocoa bindings are forcing me to put both the controller and the view within the same document nib which is no good for my application.

I'm not sure I understand what you want to end up with. You have a treecontroller in each document and want only the frontmost document's treecontroller to drive an app global outline view? You should be able to rebind the outlineview when the frontmost document changes.

Why can't you put the view and the controller in the same nib?

--------------------------
RONZILLA

_______________________________________________

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