Deinit方法永远不会被称为 - Swift游乐场
在下一个代码中,我试图调用deinit方法释放对Person Class
实例的所有引用,Mark
但是deinit从不被调用。为什么?
class Person{ let name:String init(name:String){ self.name = name println("Person created") } deinit { println("Person \(name) deinit") }}var Mark:Person? = Person(name:"Mark")Mark = nil // Shouldn't the person deinit method be called here? It doesn't.
慕标琳琳
www说