How to bind NSTreeController's Children to Core Data ordered to-many-relationship?

≯℡__Kan透↙ 提交于 2019-11-29 03:22:48

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/7039165/how-to-bind-nstreecontrollers-children-to-core-data-ordered-to-many-relationshi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!