I wrote a code block as the following:
class Person{
let name:String;
init(name:String){
self.name = name;
println("\(name) is being initialized.");
}
deinit{
println("\(name) is being deInitialized.");
}
}
var person:Person?;
person = Person(name:"leo");
person = nil;
When initialized,print
is ok. When set person to nil
,the deinit
method is not called.
deinit
method isn't called, but if I put the code into an application and run it, it is. – Tyndale