Core Data(Add new table)
- We already had Core data file(.xcdatamodel) and released
- Add totally new table(not included data change of existed table)
This is same as schema update of server side.
How to do that in iOS?
Add new version of .xcdatamodel
Point your .xcdatamodeld -> “Eidtor” -> “Add Model Version”
You name new version file name(everything is fine, but I recommend to add number or your software version).
This is my example.
Model -> Model2
Select new version
Next, we change current Core Data file.
Point your root .xcdatamodel and see File Inspector(default is right side).
You can select “Model Version” here.
Edit new version
Let’s edit Core Data file for next version.
I added new table named “CustomHoliday”.
Next is same. Create NSManagedObject by XCode.
Add column and delete column is easy. Almost all same.
The most difficult situation is change column data type.
In that case, we need to implement conversion code.
This is nice description about it!
Learning Core Data for iOS: Managed Object Model Migration