Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am visput on github.
  • I am vlad_papko (https://keybase.io/vlad_papko) on keybase.
  • I have a public key ASAwMD8ev4XyDpLoFi3lZ3KTqPWaVaX3039Uh7F4yvjsgAo

To claim this, I am signing this object:

@Visput
Visput / WeakTimer.swift
Last active January 5, 2022 06:06
Swift implementation of weak timer which automatically deallocates when target is released.
final class WeakTimer {
fileprivate weak var timer: Timer?
fileprivate weak var target: AnyObject?
fileprivate let action: (Timer) -> Void
fileprivate init(timeInterval: TimeInterval,
target: AnyObject,
repeats: Bool,
action: @escaping (Timer) -> Void) {