I recently downloaded Xcode 7 and Swift 2.0. In Swift 1.2 I set a timer with the following code.
let timer = NSTimer.scheduledTimerWithTimeInterval(8.0, target: self, selector: Selector("didTimeout"), userInfo: nil, repeats: false) I do not use the timer constant anywhere I just schedule a timer.
I was under the understanding that in order to do this I had to use the "let timer =" portion.
With Swift 2.0 I get the following warning.
Initialization of immutable value 'timer' was never used; consider replacing with assignment to '_' or removing it.
I've never seen the use of _ before so I just replaced the line above with the line below.
NSTimer.scheduledTimerWithTimeInterval(8.0, target: self, selector: Selector("didTimeout"), userInfo: nil, repeats: false) Has not using "let timer" or "var timer" always been ok in Swift or is this new in Swift 2.0?