binding Slider's value to a key, then slider's value will sync with key
How to do:
In slider's inspect, set its binding
(1)set bind to class A
(2)set A's test member as model key path
@interface AppController : NSObject {
int test;
}
@end
.m檔
// set test
[self setValue:[NSNumber numberWithInt:5]
forKey:@"test"];
// get test
NSNumber *n=[self valueForKey:@"test"];
// is called when valueForKey is called
-(int)test
{
NSLog(@"test is returning %d", fido);
return fido;
}
// is called when setValue is called
-(void)setTest:(int)x
{
NSLog(@"setTest is called with %d", x);
fido=x;
}