Couldn't find specific info about this in the doc or Google, so here is the example:
class Parent: Object {
let children = List<Child>()
}
class Child: Object {
weak var parent: Parent?
}
When I want to delete a specific Child "child1", should I just use:
Realm().write { realm.delete(child1) }
Or should I manually delete it in the parent like (cumbersome):
if let parent = child1.parent {
if let idx = parent.children.indexOf(child1) {
parent.children.removeAtIndex(idx)
}
}
Realm().write { realm.delete(child1) }
Thanks!
I just tested it myself to be sure; simply calling:
Realm().write { realm.delete(child1) }
will automatically remove it from the list. You don't need to go in and manually delete the object from the list yourself. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With