I'm observing strange behaviour of weak references to NSManagedObject. I have a container that has a weak reference to NSManagedObject:
class Container: NSObject {
weak var mo: NSManagedObject?
}
assuming that mo is some NSManagedObject I have a failed assertion in following code:
let container = Container()
container.mo = mo
mo = nil
assert(container.mo == nil) // failed
The same test case succeeds if I use NSObject instead of NSManagedObject (both container.mo and mo). The context of mo doesn't retain its objects (by default).
Whats going on here, why the weak reference doesn't get nilled automatically? Is this behaviour documented?
Aucun commentaire:
Enregistrer un commentaire