I have made a data model, and now I’ve made a 2nd version. All of the generated NSManagedObjects mapped to that data model are all version 1. Is there some way to update them to v2 without deleting them and then saying having them generated again?
Share
If you have two versions of your model you need to either create a mapping model between the two versions or you need to turn on automatic migration if the changes are simple enough for Core Data to resolve.
I would suggest reviewing Apple’s documentation on the subject of Core Data migration.
update
The
NSManagedObjectwill already have it in there, if you want to add the properties (as opposed to just the attributes) then just type in the two lines of code into yourNSManagedObjectsubclass.update
Other option, which I highly recommend, is to use mogenerator instead of the built-in code generator. mogenerator will keep the files up to date after model changes.