Created
November 19, 2012 16:24
-
-
Save johnjohndoe/4111613 to your computer and use it in GitHub Desktop.
How to bind two NSTextField instances to one NSString member
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation AppDelegate | |
@synthesize window = _window; | |
@synthesize textField1 = m_textField1; | |
@synthesize textField2 = m_textField2; | |
@synthesize foo = m_foo; | |
- (id)init { | |
self = [super init]; | |
if (self) { | |
m_foo = @"Init"; | |
} | |
return self; | |
} | |
- (void)awakeFromNib { | |
assert(m_textField1); | |
assert(m_textField2); | |
NSDictionary* textFieldBindingOptions = [NSDictionary dictionaryWithObjectsAndKeys: | |
[NSNumber numberWithBool:YES], NSValidatesImmediatelyBindingOption, | |
[NSNumber numberWithBool:YES], NSContinuouslyUpdatesValueBindingOption, | |
nil]; | |
[m_textField1 bind:@"value" toObject:self withKeyPath:@"foo" options:textFieldBindingOptions]; | |
[m_textField2 bind:@"value" toObject:self withKeyPath:@"foo" options:textFieldBindingOptions]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment