Created
September 6, 2022 21:29
-
-
Save kiarashvosough1999/111aa053222d1a364ef5dbede4be8dcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Test { | |
deinit { | |
print("Deinited") | |
} | |
} | |
let hashTable: NSHashTable<Test> = .weakObjects() | |
var optionalInstance: Test? = Test() | |
hashTable.add(optionalInstance) | |
print(hashTable.allObjects.count) | |
optionalInstance = nil | |
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { | |
print(hashTable.allObjects.count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment