Search code examples
iphonecore-datamigrationmapping-model

iPhoneOS Core Data migration: moving something from an entity into a file


I have a scenario where I'm moving the contents of a blob stored in a core data entity into a file. I need a way to export that data during a migration, where I know the entity that's being converted and save the blob to a file, writing the location of that file into the converted entity's appropriate attribute.

I can't seem to find a way to do this. The docs regarding the Three Stage Migration seem to indicate what can be done, but I'm not sure where to define things, or what exactly to define.


Solution

  • You can do this by creating a mapping model and then creating a custom NSEntityMigrationPolicy for that entity. From there you can do the modifications to your data structure as needed.