My previous question asked for a way to keep a text view and slider in sync with bindings when modifying a CGRect's "x" value.
Following Peter Hosey's advice on using the controller's setter to propogate those changes to the CALayer, I came up with the following:
@interface WindowController : NSObject {
CALayer *layer;
float frameOriginX;
}
@end
@implementation WindowController
...
-(void)setFrameOriginX:(id)value {
[layer setValue:[NSNumber numberWithFloat:[value floatValue]]
forKeyPath:@"frame.origin.x"];
frameOriginX = [value floatValue];
}
-(float)frameOriginX {
return [[layer valueForKeyPath:@"frame.origin.x"]floatValue];
}
@end
I used bindings to connect the text view and slider to "self.frameOriginX" and it's all working–both controls update each other. However, I was wondering what a cleaner way to do this is.
Thank You,
Charles