本文介绍了在具有跨越多个实体的Core Data绑定的Cocoa中实现parent>子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试以iTunes类型浏览器的风格为我的核心数据模型创建一个简单的界面。

I'm trying to create a simple interface to my core data model in the style of iTunes Genre browser.

我有一个模型设置,有三个实体: code> Genre< - >>艺术家< - >>

I have a model setup with three entities: Genre <-->> Artist <-->> Album.

我想简单地将它们绑定到一个NSTableView,但它看起来好像访问儿童关系从一个NSArrayController不是KVC兼容。因此,我无法将所选的Genre对象传递给ArtistController。

I'd like to simply tie them each to a NSTableView, but it appears as though accessing children relationships from a NSArrayController is not KVC compliant. So, I'm having difficulty communicating the selected Genre objects to the ArtistController.

如何做到这一点?

编辑Posterity:我做错了几个错误。


  • 子控制器需要通过自己的绑定知道managedObjectContext。

  • 子控制器必须位于 Entity 模式中,而是作为 NSMutableDictionary 类进行操作。

  • 最后,子控制器不准备其数据。它通过内容集绑定从父级检索它。使用控制器键 selection ,以及连接到子项的模型键路径。

  • The child controller needs to know about the managedObjectContext through its own binding.
  • The child controller must not be in Entity Mode, but rather operate as a NSMutableDictionary class.
  • And, finally, the child controller does not prepare its data. It retrieves it from the parent, through the Content Set binding. Use the controller key selection, and the model key path that connects to the children.

phew 。 Brian的答案和

The general term for this kind of setup is a "master-detail interface", and is outlined in Apple's docs at this link

这篇关于在具有跨越多个实体的Core Data绑定的Cocoa中实现parent&gt;子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:40
查看更多