Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode warns about missing Core Data relationship, but is it really bad?

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.

enter image description here

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.

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

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)

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.

like image 774
epologee Avatar asked Dec 05 '25 08:12

epologee


1 Answers

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).

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.

like image 76
Alfonso Avatar answered Dec 07 '25 23:12

Alfonso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!