views:

187

answers:

1

Apple says:

An attribute of an NSController object. When binding to an NSController object, you use this field to select the first entry in the key path. The menu associated with this field displays the properties available on the selected controller object as a convenience. You can type the name of the property or simply select it from the provided list.

Can someone explain that in other words?

+2  A: 

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.

Barry Wark