Swift: no output for println in deinit method (not using playground)
问题 This is my test code (run in the terminal): #!/usr/bin/xcrun swift var count = 0; // for reference counting class A { init() { count++; } deinit { println("A deinit") count--; } } var a: A? = A() println(count) a = nil // no output if I comment out this statement println(count) Output: 1 A deinit 0 There is no output "A deinit" if the line mentioned above is commented out. And the output will be: 1 1 I've used swiftc to compile the code but the result is still the same. ( xcrun swiftc -o test