如何绑定NSTreeController的孩子到Core Data订购多关系? [英] How to bind NSTreeController's Children to Core Data ordered to-many-relationship?

查看:161
本文介绍了如何绑定NSTreeController的孩子到Core Data订购多关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

苹果在Lion的Core Data中引入了多对多关系。我创建了一个名为TreeNode的实体,它具有1:1的对象关系,1:1的父关系和一个有序的多对多关系。

Apple introduced ordered to-many-relationships in Core Data in Lion. I created an entity named TreeNode with an 1:1-object-relation, a 1:1-parent-relation and an ordered to-many-relationship children.

我有一个 NSTreeController ,其中键的路径设置为TreeNode.children。运行应用程序只显示第一级元素。所以孩子不工作。由于孩子是一个有序的多对多关系,相应的类有一个 NSOrderedSet 的孩子。我添加了一个自定义方法

Then I have an NSTreeController with the children key path set to TreeNode.children. Running the application only shows first level elements. So children is not working. Since children is an ordered to-many-relationship, the corresponding class has an NSOrderedSet children. I added a custom method

- (NSArray *) childrenArray {
  return [children array];
}

到TreeNode。我找不到有关该主题的任何文档。将 NSTreeController 绑定到有序对多关系是真的吗?先感谢。

to TreeNode which works. I could not find any documentation concerning that topic. Is it really the way to go when binding NSTreeController to an ordered to-many-relationship? Thanks in advance.

推荐答案

似乎苹果给我们Core Data的订单集,但忘了升级其绑定控制器。

It seems that Apple gave us ordered sets for Core Data but forgot to upgrade its binding controllers. One year later after your question, the problem is still there.

查看:

https://github.com/robertjpayne/DDOutlineView

道德的故事。使用有序关系时请小心,尝试自己执行,直到Apple完全实现该功能

Moral of the story. Be careful when using ordered relationships, try to do your own implementation until Apple fully implements that feature

这篇关于如何绑定NSTreeController的孩子到Core Data订购多关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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