All iOS apps deal with data, and many apps need to save data locally. Core Data is a compelling choice for data management and persistence in iOS and OS X, which if you’re here you probably already know! :]
But what if you want to change the data model for your app after you ship? To do this, you’ll need to create something called a migration, which is a fancy way of telling Xcode how to transition the data from the old model to the new model.
There are three primary ways to create a migration: automatic (aka lightweight), manual, and custom code. In reality, the migration process may involve one or more of these techniques.
The golden rule when it comes to Core Data migrations is, choose lightweight whenever possible. Manual migrations and migrations requiring custom code are a magnitude more complex and memory intensive.
Thanks to the über smart engineers on the Core Data team at Apple, you can use lightweight migrations for an increasing percentage of your migration needs with every new release of iOS and OS X. And even when a more complex migration is necessary, you can mix in lightweight migrations to do some of the heavy lifting before you have to dig in.
In this tutorial, you will learn how to successfully perform a lightweight Core Data migration.
The app you will create in this tutorial will enable users to record passing thoughts. You know, those moments of inspiration and brilliance that happen where else but when you’re standing in line or sitting on the throne? Soon, there will be an App for that! :]
Note: This tutorial assumes you are familiar with the basics of using Core Data. If you are new to Core Data, no problem – we’ve got you covered with some great Core Data tutorials including this and this and this.