This simple code works in Xcode 9.x but does not behave the same in Xcode 10 GM. deinit
is simply never called.
class Ref {
weak var obj: Obj?
}
class Obj {
deinit {
print("deinit")
}
}
var obj: Obj? = Obj()
let ref = Ref()
ref.obj = obj
obj = nil
It gets even worth. because if you add ref.obj = nil
at the end the object still does not deallocate.
I tested it only in playground. I'll create a small project and test it there. Works in a small command line app.
Why does can this happen in playground though?