class A: Timer {
var myTimer: Timer!
}
class TimerTestViewController: UIViewController {
var a = A()
override func viewDidLoad() {
super.viewDidLoad()
a.myTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerRun), userInfo: nil, repeats: true)
RunLoop.current.add(a, forMode: RunLoop.Mode.common)
a.myTimer.fire()
}
}
Notice in RunLoop.current.add(a, forMode: .common)
that i didn't add a.myTimer
to runloop but “accidentally” added a
to the runloop.
why does this code work at all?