I am pretty new for cocoa programming. I am learning binding, trying to make a simple binding code as:
- (void)awakeFromNib
{
self.aValue = [[Model alloc] init];
NSString *aKey = @"value";
NSDictionary *aDic = [[NSDictionary alloc] initWithObjectsAndKeys:self.aValue, aKey, nil];
self.anObjctCtrler = [[NSObjectController alloc] initWithContent:nil];
[self.anObjctCtrler setContent:aDic];
NSLog(@"%ld", [[[[self.anObjctCtrler content] valueForKey:@"value"] number] integerValue]);
}
The anObjectCtrler is an NSObjectController in the Interface Builder, and I "bind" a NSTextField to Object Controller, the class of anObjectCtrler, at a model key path of "value" and controller key of "selection"; the Obeject Controller has referencing outlet to File's Owner as anObeject.
When I run the codes, the NSTextField displays "No Selection", not as expected as the value of "self.aValue". You can see I check the content of the object controller by using an output of "NSLog...", it shows the correct value.
Anyone can help me to solve this, please?
Many Thanks.