Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is replacement of NSTimer.scheduledTimerWithTimeInterval() in swift 3?

I want to implement NSTimer.scheduledTimerWithTimeInterval in Swift 3. I want to know the Replacement of

NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: #selector(createEnemy), userInfo: nil, repeats: true)

as we used it in swift 2.2

like image 599
Mohsin Qureshi Avatar asked Sep 20 '16 08:09

Mohsin Qureshi


People also ask

How do you call a timer in Swift?

A Basic timer is declared as such: //declare blank timer variable var timer = Timer() //in a function or viewDidLoad() timer = Timer. scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true) //new function @objc func timerAction(){ print(“timer fired!”) }


1 Answers

Try like this:

Timer.scheduledTimer(timeInterval: 0.35, target: self, selector: #selector(createEnemy), userInfo: nil, repeats: true)
like image 132
Leo Dabus Avatar answered Sep 28 '22 01:09

Leo Dabus