Extra argument 'selector' in call - NSTimer scheduledTimerWithTimeInterval
nstimer, swift, timer
Solution
It looks like you're missing the userInfo argument. Try this:
Swift 2
let TIMES = 1.0
var changeColour = NSTimer.scheduledTimerWithTimeInterval(TIMES, target: self, selector: "restart", userInfo: nil, repeats: true)
Swift 3, 4, 5
let TIMES = 1.0
var changeColour = Timer.scheduledTimer(timeInterval: TIMES, target: self, selector: #selector(restart), userInfo: nil, repeats: true)
Problem
I have the following line of code: ``` changeColour = NSTimer.scheduledTimerWithTimeInterval(TIMES, target: self, selector: "changeColourOfPage", repeats: true) ``` but it gives the error "Extra argument 'selector' in call" when I change the `TIMES` variable to a number like `1.0`, it works fine. The variable `TIMES` is set to `1.0`. Is this just a glitch, or am I being stupid about something? I need to use it to run a method at random intervals. Please help!