Skip to content

Instantly share code, notes, and snippets.

@kiarashvosough1999
Created September 6, 2022 21:29
Show Gist options
  • Save kiarashvosough1999/111aa053222d1a364ef5dbede4be8dcc to your computer and use it in GitHub Desktop.
Save kiarashvosough1999/111aa053222d1a364ef5dbede4be8dcc to your computer and use it in GitHub Desktop.
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