How to Disable No Inverse Relationship Warning for Coredata in Xcode 4.2

Core Data, No Inverse Relationship

First of all, you would be correct that you should implement the inverse relationships, as Xcode requires them. It's a good database practice, and you can virtually ignore the excess relationships if you're not using them.

Yes, you should be able to perform a lightweight migration, that is, create a new data model and let Xcode infer the changes. Here, Apple states that lightweight migration supports adding relationships.

Regarding your second question, true, creating another data model will not actually solve the warning in the older ones. You must leave the older models in Xcode so it can compute the lightweight migration process. If you erase a model and a user updates from an older version that uses that model, their data will be corrupted. (However, if you haven't published a version of the app with a particular data model, you can delete that data model.)

However, you can try suppressing the inverse relationship warning entirely.

  1. In Xcode, click on your project file.
  2. Click the Build Settings tab.
  3. Search for MOMC.
  4. Set Suppress momc warnings on missing inverse relationships to Yes.

EDIT about getting rid of the warnings on only the old models: This question suggests that you could move the old data model out of Xcode and place it elsewhere, and add a Copy Files action to Build Phases to copy the file back in at compile time. This way the file and it's extraneous warnings could be out of your way. Sorry there isn't a less "hacky" solution.

Core Data Warnings

If you don't need to model an inverse relationship is ok. Warnings are not errors. They are just saying that you are responsible for extra stuff as highlighted in Apple doc (in bold key parts).

It is not strictly necessary to model a relationship in both
directions. In some cases it may be useful not to, for example when a
to-many relationship may have a very large number of destination
objects and you are rarely likely to traverse the relationship (you
may want to ensure that you do not unnecessarily fault in a large
number of objects at the destination of a relationship). Not modeling
a relationship in both directions, however, imposes on you a great
number of responsibilities, to ensure the consistency of the object
graph, for change tracking, and for undo management. For this reason,
the practice is strongly discouraged. It typically only makes sense to
model a to-one relationship in one direction.

Anyway, I think you should also be able to fix the warning following this discussion: How to disable no inverse relationship warning for CoreData in Xcode 4.2?.

Hope that helps.

Entity is not key value coding-compliant for the key

Ok, Firstly, I would like to thank everyone who suggested ideas. They may not have helped me solve the problem, but I learnt more about Core Data and it is always good to find out what I should be checking when things don't work.

I don't really know what the problem was. Until this morning I had Xcode open for about 5 days I think and yesterday I added the attribute 'bestTime' to the data model. I can only assume that over the 5 days, Xcode had become a little unstable and thought it was saved when it wasn't. I had checked that I had saved the model attributes, in fact I must have checked 3 or 4 times as well as my habit of hitting Command+S after any change I make.

Anyway, I rebooted my machine earlier today and when I started up Xcode a few minutes ago I realised that 'bestTime' was not in the model file. I added it, reset the settings on the iPad simulator and it worked.

Thank you all again for the help, sorry the solution wasn't more interesting and code based. Although it makes me feel better that my code wasn't the cause.



Related Topics



Leave a reply



Submit