Jacob Relkin
Jacob Relkin

Reputation: 163308

When performing a Core Data migration, how can I carry over old values from the source store from a different entity?

I'm performing a migration using Core Data's standard mapping model approach, and it seems to be working fine, except for one thing: I've moved an attribute from one entity to another, and I want to move the underlying value from the source store to that new entity as part of the migration.

This should be possible, but I'm having trouble figuring out which steps I need to take to accomplish this.

Upvotes: 2

Views: 159

Answers (1)

Mundi
Mundi

Reputation: 80271

I think one way is to subclass NSEntityMigrationPolicy and put your logic there. There you can import the class files of the other needed entity.

In Xcode you can set the "Expression" under "Attribute Mapping" as FUNCTION($entityPolicy, "yourMethodName", $source).

Upvotes: 1

Related Questions