iOS Noob here - I am trying to run a background Timer in Swift. The below code generates this error message:
Thread 1: EXC_BAD_ACCESS (code=1, address=0xd)
It has something to do with userInfo
and I've also tried using nil
but no success.
@IBAction func startButton(_ sender: AnyObject) {
timer = Timer.scheduledTimer (
timeInterval: 0.01,
target: Any.self,
selector: #selector(ViewController.whileRunning),
userInfo: Any?.self,
repeats: true
)
}
Reading the following documentation was not helpful:
https://developer.apple.com/reference/foundation/timer/1412416-scheduledtimer#discussion
The whole point of this is to move an element around my storyboard over time using the x coordinates.