Re: Keys dependent on NSArrayController's selection
Re: Keys dependent on NSArrayController's selection
- Subject: Re: Keys dependent on NSArrayController's selection
- From: Dave Dribin <email@hidden>
- Date: Thu, 8 May 2008 13:45:20 -0500
On May 8, 2008, at 9:22 AM, Sean McBride wrote:
On 5/8/08 1:53 AM, Dave Dribin said:
For kicks, I did try
"peopleController.selectionIndex" as well as
"peopleController.selectedObjects" to no avail.
So it seems you have observed the same as I: that
keyPathsForValuesAffectingValueForKey does not seem to work with key
paths, despite the docs saying it should.
Yeah, I'm confused. I think this *should* work. Is it broken, or are
the docs just not pointing out a known limitation?
This is what I was remembering:
<http://www.cocoabuilder.com/archive/message/cocoa/2006/6/4/164955>
That's pretty clear, and I'm understanding that I *shouldn't* do
willChange/didChange. What I'm lacking is information of how to do it
the "proper" way. If keyPathsForValuesAffectingValueForKey: is not
effective, what are my options?
I guess another option is to not use bindings for the button's enabled
state, and just do it the "old fashioned way" with an outlet to the
button, along with manual KVO:
- (void)updateButtonEnabled {
[button setEnabled: self.canEnableButton];
}
- (void) awakeFromNib {
[peopleController addObserver:self
forKeyPath:@"selectionIndexes"
options:0
context:SelectionIndexesContext];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if (context == SelectionIndexesContext)
[self updateButtonEnabled];
}
-Dave
_______________________________________________
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