class Test
{
var name:String
//weak 弱引用
//unowned无主引用
lazy var data:()->Void = {[weak self]() ->Void in
print(self!.name)
}
init(name:String) {
self.name = name
}
deinit {
print("Test的示列释放:\(self.name)")
}
}
var t:Test? = Test(name: "hello")
t!.data()
t = nil
网友评论