You are binding a view object to a model property. Something like (schematically):
myTextField.value <=> myModel.textValue.
While you can bind a view property directly to your model object's property like shown above, you really shouldn't. You would miss out on the nice features provided by Apple's controllers (e.g. NSObjectController
, NSArrayController
, etc.). Instead you should bind your view to a controller which is bound to the model, like:
myTextField.value <=> myObjectController.selection.textValue
and
myObjectController.contentObject <=> myModel
In this setup, myObjectController.selection is a Key-Value binding compatible proxy for myObjectController.contentObject and myObjectController can act as a mediator between the view and the model. Interface Builder makes this separation of concerns explicit because controllers may expose multiple proxies for their bound model (such as NSArrayController
's arrangedObjects
and selectedObjects
). In binding myTextField.value in the example above, you would enter 'selection' in the "Controller Key" field and "textValue" in the "Model Object Keypath" path field.