Re: Binding to selection of NSArrayController manually
Re: Binding to selection of NSArrayController manually
- Subject: Re: Binding to selection of NSArrayController manually
- From: Stuart Malin <email@hidden>
- Date: Fri, 13 Mar 2009 08:34:38 -1000
On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote:
I have an NSArrayController subclass and an NSPopUpButton subclass.
I am trying to bind the NSPopUpButton's selected object to the
selection of my array controller.
I have to do this manually for reasons I won't get into here.
But when I do this (self is myPopUpButton)
[self bind:@"selectedObject" toObject:ArrayController
withKeyPath:@"selection" options:nil];
I get the error that my array controller is not KVC for the key path
selection.
"selection" is definitely a controller key option in Interface
Builder, is it possible that this doesn't work programmatically?
Has anyone else run into this problem???
I want to bind to the selected object, not the index... so it seems my
only option here is selectedObjects, which I will have to pass an
array of one object to.
I'm no expert in this area, but have dabbled with some code related to
this, hence I offer the following subject to proviso...
I believe the only KVObservable properties of NSArrayController that
you can use in this way are: -selectedObjects, -selectionIndex, and -
sectionIndexes.
My suggestion, as you have subclassed NSArrayController, would be to
add an additional KVO compliant property that returns the underlying
(first) selected object (not the proxy object). Implement a -
selectedObject property in your sub class and use it as the keyPath in
the bind statement.
- (id) selectedObject
{
return [[self selectedObjects] objectAtIndex:0];
}
HTH.
_______________________________________________
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