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: Quincey Morris <email@hidden>
- Date: Thu, 12 Jun 2008 11:19:39 -0700
On Jun 12, 2008, at 08:35, Danny Price wrote:
So the object is single-level tree where each leaf is the actual item
selected?
What I don't understand is why the same binding returns a different
object
in two cases? Why don't get this proxy object when I bind the view
directly
to the controller?
It looks like you're assuming that a binding involves two objects and
a keypath. In fact, a binding involves two objects and *two* keypaths.
The documentation for the NSKeyValueBindingCreation protocol says:
bind:toObject:withKeyPath:options:
Establishes a binding between a given property of the receiver and
the property of a given object specified by a given key path.
- (void)bind:(NSString *)binding toObject:(id)observableController
withKeyPath:(NSString *)keyPath options:(NSDictionary*)options
Parameters
binding
The key path for a property of the receiver previously exposed
using the exposeBinding: method.
observableController
The bound-to object.
keyPath
A key path to a property reachable from observableController.
In your case, the two keypaths are "arrangedObjects" and "name". It is
not correct (in general) to expect to be able to jam them together
into a single keypath and get the same result (or any result, as you
saw).
That's why there are two keypath fields to fill in when you set up the
binding in IB. Confusingly, IB's display of the binding (e.g.
controller.arrangedObjects.name) is a shorthand description meaningful
for display purposes only.
_______________________________________________
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