Re: NSTreeController's arrangedObjects returning _NSControllerTreeProxy for KVC path?
Re: NSTreeController's arrangedObjects returning _NSControllerTreeProxy for KVC path?
- Subject: Re: NSTreeController's arrangedObjects returning _NSControllerTreeProxy for KVC path?
- From: Ken Thomases <email@hidden>
- Date: Wed, 11 Jun 2008 18:57:49 -0500
On Jun 11, 2008, at 6: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'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.
From the -[NSTreeController arrangedObjects] documentation:
Returns a proxy root tree node containing the receiver’s sorted
content objects.
- (id)arrangedObjects
Discussion
This property is observable using key-value observing.
Special Considerations
Prior to Mac OS X v10.5 this method returned an opaque root node
representing all the currently displayed objects. This method should
be used for binding, no assumption should be made about what methods
this object supports.
In general, you should not treat NSController-derived classes as
holders of data. They are specifically for binding to.
Since the "shapeTreeController" gets its content by binding to
something else, why don't you just directly access that something
instead of trying to go through the controller? In other words,
access your model, not your controller.
Regards,
Ken_______________________________________________
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