Is there no way to use IB and the relationship of two entities to populate an OutlineView?

。_饼干妹妹 提交于 2020-01-16 18:30:13

问题


I have touched on this question in others before but after writing an answer to a previous question there got me wondering why this isn't possible - or am I missing the fact that it might be?

Given that Interface Builder is very good at graphically linking various methods and delegates and data sources, is it possible that there's no straightforward graphical means to populate an OutlineView using two entities made in a Core Data model that have a parent child relationship set up so that (I believe) there is enough information to define what parent nodes the child nodes would be listed under in the outlineview?

It confuses me as I see this as a very logical way of storing two distinct sources of information and later displaying their relationship. At the moment I am trying to work without using NSTreeController, using my own datasource, and edging into territory far beyond my current ability.


回答1:


The NSTreeController is the supposed to be the controller for outlines but it's always had problems (granted I haven't used it recently.) People have often had to roll their own.

You need a tree controller or the equivalent because the outline view display isolated objects but instead indexpaths through an object graph. The outline doesn't really understand a parent->child relationships just an indexpath relation of say 1.1 or 1.2.

If you can't get NSTreeController to work like you need, take a look at the class and write your own. For an outline you really do need something that provides an indexpath that the outline view understands.




回答2:


I believe the silence to this question and the lack of results on google suggest this is not a built-in aspect of xcode. I hope it will be in future as all the information needed is in the child-parent relationship of the entities.

Until then I'm making my own class to do so.



来源:https://stackoverflow.com/questions/5181150/is-there-no-way-to-use-ib-and-the-relationship-of-two-entities-to-populate-an-ou

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