Search code examples
cocoacocoa-bindingsnstextview

Binding to NSTextField works; binding to NSTextView doesn't?


I've got a simple master-detail project with an array of class instances, an array controller providing a selection of a specific class instance, and an NSTableView presenting the array and the selection. My class has an NSString property, and when I bind it to to an NSTextField, everything works great.

However, when I bind the same property to the Value Path field of an NSTextView, it behaves very erratically:

  • Selecting among entries in the NSTableView causes no change in the NSTextView, even though the selected objects have different values for the bound property.

  • Nothing typed into the NSTextView is copied into the property of the selection.

  • The only apparent effect of the binding is that clearing the selection in the NSTableView (e.g., clicking below all of the entries) causes the contents of the NSTextView to vanish.

Any ideas?


Solution

  • The valuePath binding is for file paths. The value binding is for strings; there're also data (RTF/RTFD) and attributedString bindings.