I'm a complete newbie and started learning Swift through an online course last week.
My problem is, that I somehow receive the same error in different projects. Every time I run the Simulator and click on one of my linked buttons, nothing happens and the Xcode gives me the following error message: "unrecognized selector send to instance". Can someone help me? :)
I followed the course very closely and got the same code as the person in video, also I started from scratch and neither did work.
class ViewController: UIViewController {
let eggTimes = ["Soft": 300, "Medium": 420, "Hard": 720]
var secondsRemaining = 60
@IBAction func hardnessSelected(_ sender: UIButton) {
let hardness = sender.currentTitle!
secondsRemaining = eggTimes[hardness]!
Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true)
}
@objc func updateTimer() {
if secondsRemaining > 0 {
print("\(secondsRemaining) seconds.")
secondsRemaining -= 1
}
}
}