I added a list to my realm object class, and i need to migrate but i keep getting this error:
"Migration is required due to the following errors: - Property 'UserIdCard.idImages' has been added."
these are my classes:
class UserIdCard: Object {
dynamic var idAccountId: Int = 0
dynamic var idName: String = ""
dynamic var idType: String = ""
let idImages = List<UserImage>()
override static func primaryKey() -> String? {
return "idAccountId"
}
}
class UserImage: Object {
dynamic var image: Data? = nil
}
And this is my migration code:
if (oldSchemaVersion < 4) {
migration.enumerateObjects(ofType: UserImage.className()) { oldObject, newObject in
newObject!["image"] = nil
}
migration.enumerateObjects(ofType: UserIdCard.className()) { oldObject, newObject in
let image = migration.create(UserImage.className(), value: Data())
let images = newObject?["idImages"] as? List<MigrationObject>
images?.append(image)
}
}
I did exactly like the example Realm provided : Link
Also i tried this : Link ,but it's not working, i tried to pass different values in "value" field but nothing worked, what is the right way to migrate a list in realm?
Thanks,