Rename the main data class

I have an application that uses CoreData.

I previously had a class called Marker that was associated with a Marker object in Core Data.

I renamed the Marker class to CoreDataMarker. So I created a new .xcdatamodel file with a new class name for the object. Then I created the .xcmappingmodel model and selected the old and new .xcdatamodel files and seemed to "automatically configure".

However, when I launch my application, he complains: β€œIt is impossible to combine models with two different objects with the nameβ€œ Marker. ”I understand that this is happening, but I have no idea how to solve it.

Do you know how?

Thanks in advance!

+1
source share
2 answers

You do not need a new xcdatamodel. Change the Class field in the entity description for your Marker to CoreDataMarker . That is all that is needed. Class implementation information does not require schema migration.

+10
source

And make sure that ONLY the current version of the data model (the latest xcdatamodel file) is included in the target file and the mapping file . It seems that the creation of other model files is performed automatically based on the information from the xcmappingmodel file.

It is not intuitive, but it is what worked for me.

0
source

Source: https://habr.com/ru/post/1205785/


All Articles