分层模型的Cocoa Bindings [英] Cocoa Bindings for hierarchical model

查看:159
本文介绍了分层模型的Cocoa Bindings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于NSCollectionView的主细节界面,
其中我想在主视图和列表+卡显示板详细视图。



董事会持有类型为List $ NSMutableArray b $ b 列表,持有 NSArray 属性 cards 类型卡
卡,具有 NSString 属性名称



关系是Board - > to-many List - > to-many Card



主接口很好。



细节界面填充了相应的列表标题
作为板。在细节界面中,我还想用每个列表的
卡填充NSPopupButton。



问题:NSPopupButton为空。



输出:[< __ NSArrayI 0x60000007b240> addObserver:forKeyPath:options:context:]。键路径:name



因此,在阅读KVO,KVC和Bindings文档后,我不知道我是否需要手动KVO的层次模型。还有输出提示name属性不是KVC / KVO兼容,但它只是一个NSString?



你建议使用NSTreeController吗?



绑定的设置如下:



BoardArrayController - >绑定到文件所有者




  • **模型键路径:板



ListArrayController - >绑定到BoardArrayController




  • **控制器键:arrangeObjects

  • **模型键路径:列表

  • **模式:类



CardArrayController - >绑定到ListArrayController




  • **控制器键:排列对象

  • **模型键路径:卡




NSPopupButton有




  • for Content:arrangedObjects

  • 内容值的控制器键:arrangeObject和模型键路径:name



建议请

解决方案

如果我理解正确,在主界面中,用户选择一个板。然后,详细界面应显示选定的板的列表。如果是, ListArrayController 应该绑定到 BoardArrayController ,控制器键 / code> (不 arrangeObjects ),模型键路径同样, CardArrayController 应该绑定到 ListArrayController ,controller key 选择,模型键路径 cards 。虽然我不清楚,如果用户必须先选择一个列表,然后看到一个弹出式列表的卡,或者弹出窗口出现在第二个收集视图中的每个项目。如果是这样,那么你将需要为每个项目单独的数组控制器,这是最简单的,如果项目视图是在单独的NIB。


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

Board, holds a NSMutableArray property lists of type List List, holds a NSArray property cards of type Card Card, has a NSString property name

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

The master interface is fine.

The detail interface gets populated with corresponding Lists' titles for a Board. Within the detail interface I also want to populate a NSPopupButton with the cards for every list.

Problem: the NSPopupButton is empty.

Output: [<__NSArrayI 0x60000007b240> addObserver:forKeyPath:options:context:] is not supported. Key path: name

So after reading KVO, KVC and the Bindings documentation I am not sure if I need to do manual KVO for this sort of hierarchical model. Also the output hints that the name property is not KVC/KVO compliant, but it's just a NSString?

Do you suggest using an NSTreeController for this?

Bindings are setup like so:

BoardArrayController -> bound to File's owner

  • ** Model key path: boards

ListArrayController -> bound to BoardArrayController

  • ** Controller key: arrangedObjects
  • ** Model key path: lists
  • ** Mode: Class

CardArrayController -> bound to ListArrayController

  • ** Controller key: arranged Objects
  • ** Model key path: cards
  • ** Mode: Class

The NSPopupButton has

  • Controller key for Content: arrangedObjects
  • Controller key for Content Value: arrangedObjects and model key path: name

Suggestions please

解决方案

If I understand properly, in the master interface, the user selects a Board. Then, the detail interface should show the selected Board's lists. If so, the ListArrayController should be bound to BoardArrayController, controller key selection (not arrangedObjects), model key path lists.

Similarly, the CardArrayController should be bound to ListArrayController, controller key selection, model key path cards. Although it's not clear to me if the user has to first select a List and then sees a pop-up with that List's cards or if the pop-up is present in each item in the second collection view. If that's the case, then you'll need a separate array controller for each item, which is easiest if the item view is in a separate NIB.

这篇关于分层模型的Cocoa Bindings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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