How to do migration for the attribute type change (String to Int16) in Swift – iOS


I’m new iOS App Development.

I have CoreData named as ABC.sqlite with 20 versions of dataModel. I have created a new Model version 21 and make version data model as the current version.

In the version 21, I have created two new attributes and renamed an existing attribute name and type. I have already set the options NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption as true, to do the lightweight migration. Also, I have set the renaming identifier for the renamed attribute.

But the attribute type change wasn’t eligible the lightWeight Migration.

So I have created a new Mapping Model as Custom NSEntityMigrationPolicy Class and mentioned the class in the Custom Policy (Right Pane inspector – under Entity Mapping). In the type Changed attribute, I have set the value expression as FUNCTION($source.<attribute name here>, "intValue").

But I still get the error as Error Reason: Source and destination attribute types are incompatible.

I’m Stuck with this, Can anyone help me out, What I’m missing while performing Migration.
I need to do lightWeight migration, including the type change in an attribute.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img