bind:toObject:withKeyPath:options: is one-way binding?
Cocoa bindings are inherently two-way, but certain behaviors (like continuous/live updating of text fields) require specific options to be set. In IB you will want to make sure that the "Continuously Updates Value" check box is checked. To get equivalent behavior programmatically, you will need to specify options
on the binding. That might look something like this:
[textview bind: NSAttributedStringBinding
toObject: obj
withKeyPath: @"text"
options: (@{
NSContinuouslyUpdatesValueBindingOption : @YES })];
It's worth mentioning that when setting up a binding programmatically, it's worth checking an equivalent binding in IB and making sure you're passing all the same settings to the programmatic binding. For instance, I see in IB that the "Allow Editing Multiple Values Selection", "Conditionally Sets Editable", and "Raises For Not Applicable Keys" options are all checked by default for an NSTextView's Attributed String binding. That would mean our programmatic binding should probably really look like:
[textview bind: NSAttributedStringBinding
toObject: obj
withKeyPath: @"text"
options: (@{
NSContinuouslyUpdatesValueBindingOption : @YES,
NSAllowsEditingMultipleValuesSelectionBindingOption : @YES,
NSConditionallySetsEditableBindingOption : @YES,
NSRaisesForNotApplicableKeysBindingOption : @YES })];