Core Data: Self referencing table

限于喜欢 提交于 2019-12-08 01:02:16

问题


I have an Entity in my Core Data model that contains a reference to itself. i.e. A Page can have a child collection of pages. When compiling i get the warning:

"Page.pages -- to-many relationship does not have an inverse: this is an advanced setting (no object can be in multiple destinations for a specific relationship)"

Now I have read that core data requires an inverse relationship to maintain integrity and would like to provide this. I don't mind my data model being changed it is an early stage of development. What is an appropriate way of dealing with this situation?


回答1:


(By request of @Aran)

Well, if the warning is that Pages.pages doesn't have an inverse relationship, have you tried adding an inverse relationship? (Maybe Pages.parent?)




回答2:


Select the pages relationship and set the inverse relationship to pages also.

edit: nvm thats if a page has more than one parent.



来源:https://stackoverflow.com/questions/4487657/core-data-self-referencing-table

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