我需要两个 NSObjectController 吗?
我正在学习可可绑定。我有两个完全不同的对象,每个对象都有一个我想与用户界面项同步的 iVar。但由于它们是两个不同的对象,并且我只能在“内容”出口上使用一个 NSObjectController,所以我还需要另一个吗?
I'm learning about Cocoa bindings. I'm having two completely different objects, each with an iVar that I want to sync with a user interface item. But since they're two different objects and I can only have on "content" outlet with one NSObjectController, do I need another one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。如果您同时绑定两个不同的对象,那么您需要两个对象控制器。(这是有道理的;每个对象一个控制器。)
但是,如果您正在创建公共列表视图/详细视图界面(如地址簿中所示),那么您应该只使用一个对象控制器,该对象控制器应该绑定到数组控制器的
selectedObject
。 (如果您将其视为当前选定对象的对象控制器,那么这也是有道理的,而当前选定对象只有一个。)Yes. If you're simultaneously binding two different objects, then you need two object controllers. (It makes a sort of sense; one controller per object.)
However, if you're creating the common list view/detail view interface (as seen in Address Book), then you should only use one object controller, which should be bound to an array controller's
selectedObject
. (This, too, makes sense, if you think of it as an object controller for the currently selected object, of which there is only one.)