I have two windows: Window A is loaded from NIB; and Window B is created programmatically.
Both windows have a NStextView: the attributedString of the textview in Window A is bound to the the property text
of a model using IB; while the attributedString of the textview in Window B is bound to text
property of the model using -[NSObject bind:toObject:withKeyPath:options:]
method.
[textview bind:@"attributedString"
toObject:obj
withKeyPath:@"text"
options:nil];
Here is the weird thing: the textview in Window B is indeed bound to the obj.text
, but the changes in the textview is never updated to obj.text
. But, if I made changes in the textview of Window A, the obj.text
and the textview in Window B are updated accordingly.
So I am thinking, the -[NSObject bind:toObject:withKeyPath:options:]
method is only for one-way binding. I couldn't find a clear explanation in the Cocoa documentations. Does any one have experience with this problem? How do you implement two-way binding in code?