Avatar
Avatar
Yuta Saito
実際の強カウント数を取る方法 @swift-5.5.3 class Foo {} let foo = Foo() print("init Foo: refCount = \(_getRetainCount(foo))") do { var closure: (() -> ())? = { [foo] in _ = foo } print("init capture: refCount = \(_getRetainCount(foo))") _ = closure closure = nil } print("deinit capture: refCount = \(_getRetainCount(foo))") (edited)
swift55 BOT 3/9/2022 9:37 AM
init Foo: refCount = 2 init capture: refCount = 3 deinit capture: refCount = 2 (edited)