如何将 NSTreeController 的子级绑定到 Core Data 有序对多关系?
Apple 在 Lion 的 Core Data 中引入了有序对多关系。我创建了一个名为 TreeNode 的实体,它具有 1:1 对象关系、1:1 父关系和有序的多对关系子关系。
然后我有一个 NSTreeController ,其子键路径设置为 TreeNode.children 。运行应用程序仅显示第一级元素。所以孩子们没有工作。由于children是一个有序的多对多关系,相应的类有一个NSOrderedSet
children。我
- (NSArray *) childrenArray {
return [children array];
}
向 TreeNode 添加了一个有效的自定义方法。我找不到有关该主题的任何文档。将 NSTreeController 绑定到有序的多对多关系时,这真的是正确的方法吗?提前致谢。
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.
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];
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple 似乎为我们提供了 Core Data 的订购集,但忘记升级其绑定控制器。在你提出问题一年后,问题仍然存在。
看看:
https://github.com/robertjpayne/DDOutlineView
这个故事的寓意。使用有序关系时要小心,尝试自己实现,直到 Apple 完全实现该功能
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.
Have a look at:
https://github.com/robertjpayne/DDOutlineView
Moral of the story. Be careful when using ordered relationships, try to do your own implementation until Apple fully implements that feature