使用两个 NSTableView 的绑定的主从细节
我有一个显示在 NSTableView 中的对象列表(绑定到 NSArrayController)。当您在该列表中选择一个对象时,我想在第二个 NSTableView 中显示详细视图。我的对象有一个数组属性。我不知道如何为此连接绑定。绑定到 NSArrayController 的选择不起作用,因为这是一个单一的对象,而 NSTableView 期望绑定到一个数组......
I have a list of objects displayed in an NSTableView (bound to an NSArrayController). When you select an object in that list I want to show a detail view in a second NSTableView. My object has an array property. I can't figure out how to wire the bindings for this. binding to NSArrayController's selection doesn't work, as that's a single object, and NSTableView expects to be bound to an array...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

创建第二个
NSArrayController
并使用selection.<对象数组属性的名称>
的键路径将其内容绑定到第一个控制器。因此,如果您的第一个表视图显示类
Person
的对象,并且您的Person
类具有children
属性,则您将绑定第二个数组控制器到selection.children
。对于要在表视图中管理的每个阵列,您需要一个单独的阵列控制器。
Create a second
NSArrayController
and bind its contents to the first controller using a keypath ofselection.<name of your object's array property>
.So, if your first table view is displaying objects of class
Person
and yourPerson
class has achildren
property, you would bind the second array controller toselection.children
.You need a separate array controller for each array that you want to manage in a table view.