gpt4 book ai didi

cocoa - NSObject Controller 的选择是什么?

转载 作者:行者123 更新时间:2023-12-03 16:45:45 24 4
gpt4 key购买 nike

在 Xcode 6.2 中,在绑定(bind)检查器中我看到:

enter image description here

谁能解释一下将 Controller 键设置为选择意味着什么?苹果文档说:

selection:
Returns a proxy object representing the [NSObjectController's] selection.

一点帮助都没有。

最佳答案

我已经拼凑出了部分谜题。来自 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.

来自 SO post :

For an NSObjectController, the selection is the content object.

显然,NSObjectController 的选择@property 被分配了contentObject,这使您能够进行绑定(bind)。

更多 generally :

NSObjectController and its subclasses ... support tracking of the currently selected object or objects

我认为当前选择的对象必须表示在 View 中选择的控件。

There are two methods that are commonly used to access the objects that are currently selected: selection and selectedObjects.

我认为对于 NSObjectController,View 中选择的控件是没有意义的,因此 NSObjectController 的选择 @property 被分配给了 contentObject。

关于cocoa - NSObject Controller 的选择是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30450203/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com