There are sometimes when I need to update Core Data from existing version to a new version. In other words, I need to update Core Data database with changes on some entities. Apple provides very good framework to do that: Lightweight Migration. Here are my notes on how to add a new version to Core Data.
I am using my TapToCount-3W project as example.
In Xcode, select the data model in Project navigator:
From menu Editor
, you will find Add Model Version...
.
Accept the default settings or make changes if you need. Make sure the base version is the most active version as base. In this case, I accept TapToCount 1.3
as my new version.
Change the property settings: identifier to 1.3 and current version to 1.3. A new version of database model is created and ready for update.
As it is indicated in Project navigator:
References
- Apple Developer Document: Lightweight Migration
- Apple Developer Document: Core Data Model Versioning and Data Migration
0 comments:
Post a Comment