In the code below, I receive the error - Type 'Timer' has no member 'scheduledTimer' - which I thought was an import issue but seems to be constant despite the results. How can I remove this error from the following code?
import UIKit
import Foundation
class TimerInterfaceViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// scheduling a timer in repeat mode after each 2 seconds.
let timer = Timer.scheduledTimer(timeInterval: 2,
target: self,
selector: #selector(handleTimerExecution),
userInfo: nil,
repeats: true) -> "Type 'Timer' has no member 'scheduledTimer'"
}
@objc private func handleTimerExecution() {
print("timer executed...")
}
}
}
The answer was ensuring that there is no other class called "Timer"!