"CoreData does not maintain a constant relationship between repositories" despite matching x-coredata identifiers

When I save the context of a managed data object in iOS 6.0.1 to SQLite repository, I run the strange exception "CoreData does not maintain a constant relationship between repositories." This is a one-to-one relationship between quotes and abstract sources in the model. At run time, this applies to the quote and book (where the book is inherited from AbstractSource. Everything works well in the model editor.)

I investigated similar reports and examined the reasons given:

  • I assign both the quote and the book to the same persistent store using assignObject: toPersistentStore :, so that no unassigned ones remain.
  • The error description shows that all the "absolute" x-coredata identifiers begin with the same prefix (for example, "x-coredata: // 82B3BEB3-60F2-4912-AC80-11AAD29CFF99 /", so it really seems there that only one store is used .

My questions are as follows:

  • Is there anything else I need to check (maybe sg. In relation to AbstractSource, which I don’t touch / control in my source? I'm creating both a quote and a book calling initWithEntity: insertIntoManagedObjectContext each.)
  • I noticed that the error description also includes several "relative" x-coredata ids (forms of "x-coredata: /// ..."). Could that absolute form always be considered as a "cross-database", even if the "absolute" prefixes (see example above) are the same? And if so, how can I influence any choice between the “absolute” and “relative” x-coredata identifiers?

Thank you (a lot) for your attention!

+7
source share
1 answer

So this is what (supposedly) caused the problem:

  • The context coordinator of the managed object must manage two permanent stores. Now the one to which I assigned a Quote and a book, and I wanted them to be saved reset at startup. There was an error in this code, which makes this store unusable. Since the second was available, he was silent, in this case leading to undesirable results. Lesson: now I claim that after setting up the base data stack, there are / are two repositories left.
  • During the earlier development of my Core Data model, I renamed some of its entities in the model editor. By mistake, I only changed the names, but not the properties of the object class. Thus, everything worked well in the model editor, and then, unexpectedly, classes were used at runtime and, therefore, unexpected classes, where they were also assigned to unexpected / incorrect stores. Lesson: now I'm sure that the names of objects and their class properties remain in perfect synchronization (other circumstances allowing).

Now the problem is resolved, and I also reorganized my code / model to use (non-overlapping) configurations instead of explicit assignments, which should also contribute to further progress.

Thanks again for your attention.

0
source

All Articles