使用两个NSTableView绑定使用主从 [英] Master-detail using bindings with TWO NSTableViews

查看:73
本文介绍了使用两个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...

推荐答案

创建第二个 NSArrayController 并使用 selection的键路径将其内容绑定到第一个控制器。<对象的数组属性的名称>

因此,如果您的第一个表格视图显示的是 Person 类的对象,而您的 Person 类具有一个 children 属性,您可以将第二个数组控制器绑定到 selection.children

So, if your first table view is displaying objects of class Person and your Person class has a children property, you would bind the second array controller to selection.children.

对于要在表视图中管理的每个数组,您需要一个单独的数组控制器。

You need a separate array controller for each array that you want to manage in a table view.

这篇关于使用两个NSTableView绑定使用主从的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆