Cocoa bindings, KVC, and KVO are starting to make my head hurt. All I want to do is have an NSTextField's value bound to the value of a property of my view controller. Could someone tell me where I'm going wrong? Any help would be greatly appreciated. Below is a simplified version of what I've got going on.
MyViewController.h:
#import <Cocoa/Cocoa.h>
@interface MyViewController : NSViewController
@property NSString *colorSpaceName;
@property IBOutlet NSTextField *colorSpaceLabel;
@end
MyViewController.m:
#import "MyViewController.h"
@implementation MyViewController
@synthesize colorSpaceName;
- (id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil
{
// ...
if ( self ) {
[self.colorSpaceLabel bind:@"stringValue"
toObject:self
withKeyPath:@"colorSpaceName"
options:nil];
}
// ...
}
@end