Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

timer functionality in swift stack overflow

works on swift5.0
var timer = Timer()
var secondsPassed = 0
var totalTime = 300
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(self.update), userInfo: nil, repeats: true)
@objc func update() {
        if secondsPassed < totalTime{
            secondsPassed += 1     
        }else{
            timer.invalidate()
            print("Time's up")
        }
 
PREVIOUS NEXT
Tagged: #timer #functionality #swift #stack #overflow
ADD COMMENT
Topic
Name
4+2 =