Contents

NSCustomMigrationStage

An object that enables you to participate in the migration between two versions of the same model.

Declaration

class NSCustomMigrationStage

Overview

Use NSCustomMigrationStage when you have two versions of a model that Core Data can’t automatically migrate. Custom migration stages enable you to participate in the migration process by assigning handlers that the stage invokes before and after it runs. The handlers provide an opportunity to prepare the persistent store’s data for the upcoming changes before the stage runs, and perform any cleanup tasks afterward.

For example, to support a migration that changes an optional attribute to be nonoptional, you might assign a handler to the stage’s willMigrateHandler property that sets any nil instances of that attribute to a default value, thereby ensuring the migration succeeds. To access the store you’re migrating, use the container property of the migration manager that Core Data provides to every handler.

Topics

Creating a custom migration stage

Accessing model references

Assigning event handlers

See Also

Migration stages