Could not find specific information about this in a document or Google, so here is an example:
class Parent: Object {
let children = List<Child>()
}
class Child: Object {
weak var parent: Parent?
}
When I want to remove the specific child "child1", should I just use:
Realm().write { realm.delete(child1) }
Or I need to manually delete it as a parent (cumbersome):
if let parent = child1.parent {
if let idx = parent.children.indexOf(child1) {
parent.children.removeAtIndex(idx)
}
}
Realm().write { realm.delete(child1) }
Thanks!
source
share