uiprogressview - Swift progressView Running in background -


hello new coding. m creating app uses progressviews show employee been on break.

it runs expected while app showing once press home button , return app later progress stopped or inaccurate. have looked around , understand after 5 minutes app suspended or something. can add piece of code have bit more time nothing much. if break set 1 hour not help; here piece of code. appreciated

var time: float = 0.0 var timer: timer? var timeinterval: float = 0.01

func start(myprogressview: adprogressview ) {     timer?.invalidate()     if self.time >= float(self.breakduration * 60) { self.time = 0.0 }     self.timer = timer.scheduledtimer(withtimeinterval: timeinterval(self.timeinterval), repeats: true) { _ in         self.increment(progressview: myprogressview)     } }  func reset(progressview: adprogressview) {     timer?.invalidate()     time = 0.0     progressview.setprogress(0.0, animated: false) }  func increment(progressview: adprogressview) {     time += timeinterval     progressview.setprogress(time / float(breakduration * 60), animated: false)     if time >= float(breakduration * 60) {         timer?.invalidate()         self.wakeupalarm()     } }  func wakeupalarm () {     audioservicesplayalertsound(systemsoundid(1034)) } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -