In Xcode 6.2, in the Bindings Inspector I see this:
Can anyone explain what setting the Controller Key
to selection
means? The Apple docs say:
selection:
Returns a proxy object representing the [NSObjectController's] selection.
Not at all helpful.
I've pieced together part of the puzzle. From Apple Developer docs :
Controllers require content to manipulate and there are a number of options for setting this content. It can be done ... through bindings...
...
NSObjectController and its subclasses are initialized with the method initWithContent:, passing a content object or nil if you intend to use the content bindings. You can explicitly set the content of an existing controller using the setContent: method. It is far more common to provide content for controllers by establishing a binding to one of their exposed Controller Content bindings.NSObjectController exposes a single binding for content called contentObject . You can establish a binding from contentObject to any object that is key-value-coding and key-value-observing compliant for the keys that you intend to have the controller operate on.
From an SO post :
For an NSObjectController, the selection is the content object.
Apparently, the selection @property of the NSObjectController is assigned the contentObject, which is the thing that enables you to do bindings.
More generally :
NSObjectController and its subclasses ... support tracking of the currently selected object or objects
I think currently selected object must mean the control that is selected in the View.
There are two methods that are commonly used to access the objects that are currently selected: selection and selectedObjects.
I think that with an NSObjectController, the selected control in the View is meaningless, and therefore the selection @property of the NSObjectController is assigned the contentObject.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.