NSCollectionView Master详细绑定配置 [英] NSCollectionView Master detail binding configuration

查看:108
本文介绍了NSCollectionView Master详细绑定配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中具有以下模型.

I have the following models in my application.

  • Board,下面具有类型为List的NSMutableArray属性lists
  • List,下面拥有Card类型的NSArray属性cards
  • Card,具有NSString属性name
  • Board, holds a NSMutableArray property lists of type List below
  • List, holds a NSArray property cards of type Card below
  • Card, has a NSString property name

关系就是董事会->对多名单->对多卡

The relationship is thus Board --> to-many List --> to-many Card

我有一个基于NSCollectionView的主从界面, 我要在其中显示母版中的木板及其相应的列表+卡片的详细信息 视图.

I have a NSCollectionView based master-detail interface, where I want to display Boards in the master and its corresponding Lists+Cards in the detail view.

主界面很好,元素Board显示得很好.

The master interface is fine, the elements Board are displayed nicely.

BoardArrayController->绑定到文件的所有者

BoardArrayController -> bound to File's owner

  • **模型关键路径:木板
  • **模式:班级
  • **项目原型:董事会查看项目

ListArrayController->绑定到BoardArrayController.

ListArrayController -> bound to BoardArrayController.

  • **控制器键: arrangedObjects 选择
  • **模型键路径:列表
  • **模式:班级
  • **项目原型:列表视图项目
  • ** Controller key: arrangedObjects selection
  • ** Model key path: lists
  • ** Mode: Class
  • ** Item prototype: List View Item

CardArrayController->绑定到ListArrayController

CardArrayController -> bound to ListArrayController

  • **控制器键: arrangedObjects 选择
  • **模型密钥路径:卡
  • **模式:班级
  • ** Controller key: arrangedObjects selection
  • ** Model key path: cards
  • ** Mode: Class

主集合视图具有绑定到BoardArrayController的内容

The master collection view has the Content bound to BoardArrayController

  • **控制器键:rangedObjects

详细信息收集视图具有绑定到BoardArrayController的内容

The detail collection view has the Content bound to the BoardArrayController

  • **控制器键:选择
  • **模型键路径:列表

原型视图中的任何view元素(随NSCollectionView添加的元素)具有以下信息

Any view element in the prototype views (those that are added with the NSCollectionView) have the following info

  • **绑定到:板查看项(主)或列表查看项(详细)
  • **模型键路径:presentedObject,后跟.property

当我在主视图中单击一个面板时,详细信息界面没有更新.我希望显示一组新的列表+卡片.只是显示了启动时加载的那个.

The detail interface is not updated when I click a board in the master view. I expect a new set of lists+cards being displayed. It is only the one loaded at startup which is being displayed.

这是NSCollectionView选择问题还是绑定问题?

Is this a NSCollectionView selection problem or a binding problem?

提示:我认为这是一个有约束力的问题.因为它有效,所以如果在我的控制器中观察到masterView.selectionIndexes并将IBOutlet绑定到detailedView.然后在observeValueForKeyPath:ofObject:change:context:中,我手动调用detailedView:setContent:.

Hint: I think it's a binding problem. Because it works, if in my controller I observe masterView.selectionIndexes and bind an IBOutlet to detailedView. Then in observeValueForKeyPath:ofObject:change:context: I manually call detailedView:setContent:.

根据 Cocoa中的答案更新了设置说明层次模型的绑定

推荐答案

最后从cocoa-dev邮件列表中得到了答案(感谢Willeke).

Finally got an answer from the cocoa-dev mailing list (thanks Willeke).

解决方案

主视图selectionIndexes绑定到BoardArrayController.使用控制器键selectionIndexes.

The master view selectionIndexes is bound to BoardArrayController. With Controller Key selectionIndexes.

然后,应将详细视图内容设置为ListArrayController和Controller Key Path arrangedObjects

The detailed view content should then be set to ListArrayController and Controller Key Path arrangedObjects

这篇关于NSCollectionView Master详细绑定配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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