From my understanding, the error is coming from something being set to "nil". The only thing set to "nil" in my code is the userInfo which should be "nil" since there will never be any data there. Any help is appreciated!
import UIKit
class ViewController: UIViewController {
let eggTimes = [
"soft": 300, "medium" : 420, "hard" : 720 ]
var secondsRemaining = 60
var timer = Timer()
@IBAction func hardnessSelected(_ sender: UIButton) {
timer.invalidate()
let hardness = sender.currentTitle!
secondsRemaining = eggTimes[hardness]!
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
}
@objc func updateTimer() {
//example functionality
if secondsRemaining > 0 {
print("\(secondsRemaining) seconds to the end of the world")
secondsRemaining -= 1
}
}
}