While a view is displaying, I need to call a function in its view controller repeatedly – perhaps once every second. If the user moves away from the view (by going down or up the stack in the containing navigation controller) the timer should stop. When they move back to the view, the timer should resume.
How do I achieve this? Is there anything in particular I need to consider (if the user switches out of the app, or takes a call?)
Use
- (void)viewWillAppear:(BOOL)animatedand- (void)viewWillDisappear:(BOOL)animatedto set/reset yourNSTimer.