0

I'm working on a project where i have to create a countdown timer, just like timers used in some recipe apps. My question is that how do i go about creating a timer class/viewcontroller that can be called (by tapping on custom statusbar) from any view within the app... i believe it would not be a normal view controller since this one has to continue updating timer label on the UI even if it's hidden and not on the display. is it a good idea to create timer's view in appdelegate and keep it hidden till it gets called??

seeking professional's advice!

DevCali
  • 398
  • 6
  • 20

2 Answers2

0

Distinguish model, view, and controller. The time may continue to count, and that might indeed be because the app delegate has an NSTimer. But the timer view does not need to keep updating, or even exist, if it is hidden. If you need to show it, you create it, and it consults the NSTimer, the app delegate, or whatever the central model keeper is, and updates itself.

So it may look as though the same view is appearing in different places in your interface but actually it is a new view instance each time. This could be because it is a new view controller instance. The view controller instance and its view comes into existence when needed and goes back out of existence when not needed, but the timer just keeps on keeping on.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

It could be a "normal" uiviewcontroller, you only need add a NSTimer, it will call some selector (here you can update your custom bar) after passed certain amount of time.

Gerard
  • 360
  • 3
  • 9