Aidan Kaiser
Aidan Kaiser

Reputation: 521

How to add a timer to a function - IOS Swift

Say I had a function, any function, that I wanted to run for only three seconds and then never run again. How would I do this? Would I use NSTimer? Thank you for your help.

Upvotes: 0

Views: 100

Answers (1)

Shamsudheen TK
Shamsudheen TK

Reputation: 31311

Here you go,

NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: Selector("updateProgress:"), userInfo: nil, repeats: false)

func updateProgress(timer: NSTimer){
}

Upvotes: 1

Related Questions