Hi all! This error has been reported in GitHub too, but it seems there are still no solutions.
As the title states, app crashes when trying to update an object that has another realm object as a property.
In my case I have
class ServiceEntity: Object {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var name: String
@Persisted var iconName: String
@Persisted var mainColor: String
@Persisted var secondaryColor: String
@Persisted var _partitionValue: String = AppInfo.partitionValue
@Persisted var serviceType: ServiceType?
convenience init(name: String, mainColor: String, secondaryColor: String, iconName: String, serviceType: ServiceType) {
self.init()
self.name = name
self.mainColor = mainColor
self.secondaryColor = secondaryColor
self.iconName = iconName
self.serviceType = serviceType
}
}
and
class ServiceType: Object {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var name: String
@Persisted var iconName: String
@Persisted var mainColor: String
@Persisted var secondaryColor: String
@Persisted var _partitionValue: String = AppInfo.partitionValue
convenience init(name: String, mainColor: String, secondaryColor: String, iconName: String) {
self.init()
self.name = name
self.mainColor = mainColor
self.secondaryColor = secondaryColor
self.iconName = iconName
}
}
Creating a new ServiceEntity
object and setting serviceType
property works flawlessly. Updating a ServiceEntity
object modifying the serviceType
property always crashes with
*** Terminating app due to uncaught exception ‘RLMException’, reason: ‘Can’t set object of type ‘ServiceType’ to property of type ‘ServiceType’’
It always happens