核心数据:自引用表 [英] Core Data: Self referencing table

查看:162
本文介绍了核心数据:自引用表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的核心数据模型中有一个实体,它包含对自身的引用。即页面可以具有页面的子集合。当编译时,我得到警告:

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 - 一对多关系没有逆:这是一个高级设置(没有对象可以在多个特定关系的目的地)

"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?

推荐答案

(根据@Aran的要求)

(By request of @Aran)

那么,如果警告是Pages.pages没有反向关系,你试过添加一个反向关系? (Maybe Pages.parent?)

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

这篇关于核心数据:自引用表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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