使用两个 NSTableView 的绑定的主从细节

发布于 12-15 17:57 字数 195 浏览 5 评论 0原文

我有一个显示在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撕心裂肺的伤痛2024-12-22 17:57:41

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

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

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

Create a second NSArrayController and bind its contents to the first controller using a keypath of selection.<name of your object's array property>.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文