Search code examples
objective-cmacoscore-datacore-data-migration

How to add default string to attribute during CoreData migration


I have a simple Coredata program for cataloging some data - coded in Objective-C. A new model version was created that has a new attribute. A mapping model has been created, it is not inferred. The migration is working great, however, after migration the new attribute is empty - which is expected. I would like to add a placeholder string value to the new attribute during the migration process. The two thoughts I have is to either place custom code in the value expression of the mapping model or subclass NSMigrationPolicy and add code there, but I have not found much information regarding either. Any suggestions?

Thank You in advance


Solution

  • The Value Expression in the mapping model can be a constant value expression like string "placeholder" or integer 1.