Avatar ·

How to use @selector() in Swift for NSTimer and other methods?

Hi everyone! I'm new to Swift and trying to figure out selectors. I have experience with Objective-C, where I often used @selector() to pass methods to timers or event handlers. For example, I want to create a simple timer that calls a method every second. Here's my code in Swift: ```swift import UIKit class ViewController: UIViewController { var timer: Timer? override func viewDidLoad() { super.viewDidLoad() // Trying to create a timer, but don't know how to write the selector correctly timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true) } func updateTimer() { print("Timer fired!") } } ``` But Xcode gives an error: "Argu