ios - Realm: Can't update a object if one of its properties is another object that already exists -
i have schema:
class a: object { var ida = "" var b: b? override class func primarykey() -> string { return "ida" } } class b: object { var idb = "" var name = "" override class func primarykey() -> string { return "idb" } }
so if want save object:
func updatea(a: a, b: b) { { try realm.write { a.b = b //here excepcion realm.add(a, update: true) } } catch { error } }
when call update can't assign b a.b, get: *** terminating app due uncaught exception 'rlmexception', reason: 'can't create object existing primary key value "bkey".' if b object exists in database primary key that, if new object works. im pretty sure long time ago worked expected notice want save updating b object if 1 of properties has changed, name. , dont wanto create b object, use b object passed.
it's expected isnt it, adding b
created create similar one, that's not possible since having b
primary key already
what should create a
new b
, not create b
first assign a
Comments
Post a Comment