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

Mohsin Qureshi picture Mohsin Qureshi · Sep 20, 2016 · Viewed 13k times · Source

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

Answer

Leo Dabus picture Leo Dabus · Sep 20, 2016

Try like this:

Timer.scheduledTimer(timeInterval: 0.35, target: self, selector: #selector(createEnemy), userInfo: nil, repeats: true)