2008 06 05One way binding to NSSlider
NSSlider's value to another object. I figured it would be nice to set the slider's value in IB and have it act as default for the bound object. While binding the slider to the object (
[myObject bind:@"opacity" toObject:opacitySlider withKeyPath:@"value" options:nil];), my code kept crashing with
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSSlider 0x125040> valueForUndefinedKey:]: this class is not key value coding-compliant for the key value.'
NSSlider does not have a value key ? That's new ! It's there in IB, it shows up in its exposedBindings … Turns out only one way is supported : binding the view (slider) to the object.
[myObject bind:@"opacity" toObject:opacitySlider withKeyPath:@"value" options:nil];
[opacitySlider bind:@"value" toObject: myObject withKeyPath:@"opacity" options:nil];
[slider valueForKey:@"value"]will crash, too. I suppose all the controls act alike, that means there's no KVC way to interact with them.