import UIKit
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)
func updateTimer() {
if secondsRemaining > 0 {
print("\(secondsRemaining) seconds.")
secondsRemaining -= 1
}
}
}
} strong text I am taking this Udemy course where it seems to be working fine but on my system, it is not working at all.
Read more here: https://stackoverflow.com/questions/66336708/how-do-i-solve-this-error-argument-of-selector-cannot-refer-to-local-functio
Content Attribution
This content was originally published by Sachin Kashyap at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.