XCode对丢失核心数据关系提出警告,但这真的很糟糕吗?

时间:2021-06-17 06:54:16

Picture a core data model with images in it. These images are stored in an object called OImage. There are several other objects that 'contain' images, so they all have a one to many relationship with the OImage object. One example is the OLocation object from the image.

想象一个包含图像的核心数据模型。这些图像存储在一个名为OImage的对象中。还有其他一些“包含”图像的对象,所以它们都与OImage对象有一到多个关系。一个例子是图像的定位对象。

XCode对丢失核心数据关系提出警告,但这真的很糟糕吗?

As you can see, OLocation has a one to many relationship with OImage. Because there is no need for it, there is no inverse relationship from the OImage pointing back to OLocation. All according to plan.

正如您所看到的,OLocation与OImage关系密切。因为不需要它,所以在OImage中没有反向的关系指向OLocation。一切按计划进行。

Yet when I build my project, XCode keeps warning me about the lack of the inverse relationship:

然而,当我构建我的项目时,XCode一直在警告我缺少反向关系:

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

OLocation。图像——多对多关系没有反向:这是一种高级设置(对于特定的关系,任何对象都不能位于多个目的地)

Is it illegal to create a one-to-many relationship without the inverse? Or is this warning something that I can somehow turn off?

创建一对多关系而不使用逆关系是否违法?或者这个警告是我可以关掉的吗?

Cheers, EP.

干杯,EP。

1 个解决方案

#1


9  

It is perfectly legal, but not often advisable to have a unidirectional relationship. This link explains this in more detail (from Core Data Programming guide).

这是完全合法的,但通常不建议有一个单向的关系。这个链接更详细地解释了这一点(来自Core Data编程指南)。

You can however turn the warning off, by adding a new property to the build settings called MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS and set its value to YES.

但是,可以通过向名为momc_no_inverse_relationship_warning的构建设置添加一个新属性并将其值设置为YES来关闭警告。

#1


9  

It is perfectly legal, but not often advisable to have a unidirectional relationship. This link explains this in more detail (from Core Data Programming guide).

这是完全合法的,但通常不建议有一个单向的关系。这个链接更详细地解释了这一点(来自Core Data编程指南)。

You can however turn the warning off, by adding a new property to the build settings called MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS and set its value to YES.

但是,可以通过向名为momc_no_inverse_relationship_warning的构建设置添加一个新属性并将其值设置为YES来关闭警告。