O'Reilly logo

Core Data in Swift by Marcus S. Zarra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fundamentals of Core Data Versioning

We’ve seen the nuts and bolts, but what’s the magic behind all of this? How does the data migration actually work? As we already explored in Chapter 2, Under the Hood, Core Data works with MOM (NSManagedObjectModel) objects that describe the data entities, their attributes, and their relationships.

Core Data versioning works with those same MOM objects but takes the design one step further.

Each entity version in each data model has a unique hash.

When Core Data loads a persistent store from disk, it resolves the matching hashes in the persistent store against the MOM objects included with the application.

If the matching MOM isn’t flagged as the “current” MOM, data migration will then kick in.

How Data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required