我在Swift playground
中编写了以下代码:
class View : UIView {
let name = "myView"
deinit {
print("deinit View")
}
}
class Controller: NSObject {
var view: View
init(view : View) {
self.view = view
super.init()
}
deinit {
print("deinit Controller")
}
}
var c : Controller? = Controller(view: View())
c = nil
控制台显示:
deinit Controller
我的问题不应该像下面那样?
deinit Controller
deinit View