Search code examples
iosuiviewcontrollerparent-childparentnstimer

Preserve parent viewController timers


I have a huge doubt regarding a feature I'm developing, let me explain the situation:

I have a viewController A that every 10 seconds calls a webService with a NSTimer. When the response from that webService changes, viewController B is being pushed and shown. This works perfectly fine.

My question is. The user may call an InfoViewController from view Controller A. I need "A" to keep consuming the webService (even if InfoView is on top) and when the response changes, "A" should dismiss InfoView to call "B".

How would you suggest to do this?

Thank you very much in advance!


Solution

  • The timers will continue to run even if another ViewController is shown. If you keep a reference to your InfoViewController, when the webservice changes, check to see if the InfoViewController is visible (check if it's nil, or whether it has a parent) and dismiss it.