I have tried many approaches that I have found in other questions and any of them are working. My problem is that the timer is not calling selector
class MyViewController: UIViewController{
var progressBarTimer = NSTimer()
@IBOutlet weak var progress_bar: UIProgressView!
override func viewDidLoad() {
self.progress_bar.progress = 0
self.progressBarTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(MyViewController.updateProgress(_:)), userInfo: nil, repeats: true)
//also tried and redefining the updateProgress without timer parameter:
/*
*self.progressBarTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(MyViewController.updateProgress), userInfo: nil, repeats: true)
*/
}
func updateProgress(timer:NSTimer!) {
progress_bar.progress += 0.1
if (progress_bar.progress >= 1) {
progressBarTimer.invalidate()
}
}
}
I have tried to do
progressBarTimer.fire()
and it just executes once the updateProgress function.
Could anyone shed light on? I would really appreciate