Skip to content

Instantly share code, notes, and snippets.

@kiarashvosough1999
Created September 7, 2022 21:43
Show Gist options
  • Save kiarashvosough1999/b9cf2259339839f2e9facc8c092e547d to your computer and use it in GitHub Desktop.
Save kiarashvosough1999/b9cf2259339839f2e9facc8c092e547d to your computer and use it in GitHub Desktop.
Test++Count++NSHashTable
class Test: NSObject {
deinit {
print("deinit")
}
}
let tests = NSHashTable<Test>.weakObjects()
var test: Test? = Test()
tests.add(test)
print("count:\(tests.count) allObjects.count\(tests.allObjects.count)")
test = nil
Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in
print("count:\(tests.count) allObjects.count:\(tests.allObjects.count)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment