Source code written with the intention of Swift 2.2.
timer=NSTimer.scheduledTimerWithTimeInterval(0.1,self,selector:#selector(ViewController.timeCheck(_:))),userInfo:nil,repeats:true)}
This will result in an error.
This error did not appear in Swift 2.1.
The following sources did not appear in Swift 2.1.
timer=NSTimer.scheduledTimerWithTimeInterval (0.1, target:self, selector:Selector("timeCheck:"), userInfo:nil, repeats:true)
Where and how should I fix it?
swift2
The second argument of the scheduledTimerWithTimeInterval()
method is unlabeled if the code is not miswritten.
This is one of the signature methods on the argument label, so if you forget to write it, it becomes a different method.
timer=NSTimer.scheduledTimerWithTimeInterval (0.1, target:self, selector:#selector(ViewController.timeCheck(_:), userInfo:nil,repeats:true)
^You must write 0.1, target:self,selector:...
as shown above.
© 2024 OneMinuteCode. All rights reserved.