Reputation: 51
I have a iOS app that has a core data database for news. Each of the news entities has a ID attribute, which should be a Integer but until now, it is a String and I want to change it to be a Integer.
Steps I have tried until now:
import CoreData
class ModelV2MigrationPolicy: NSEntityMigrationPolicy {
func idToInt(old: String) -> Int32 {
return Int32(old)!
}
}
But if I now try to run my app, it crashes with the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myapp.ModelV2MigrationPolicy idToInt]: unrecognized selector sent to instance
Any ideas how to fix this?
Upvotes: 3
Views: 760
Reputation: 21
The problem is that your selector in FUNCTION($entityPolicy, "idToInt:" , $source.id)
is wrong.
Based on your method func idToInt(old: String)
the selector should be "idToIntWithOld:"
Upvotes: 2