My application downloads content from a server, as soon as this has finished it parses its content any may also display it. If it displays it then a VC is pushed onto the navigation stack.
During the course of processing the content it may be necessary to schedule a local notification.
When the notification fires a VC is also pushed onto the navigation stack to display something.
I have a problem where the local notification expires immediately – the problem is that in this situation the push of the 2nd VC is happening before the viewDidAppear: from the first VC push has executed.
I could detect if the notification is going to expire immediately and add a delay – but that seems not ideal (adding timers to solve problems is never a very good solution IMO, how much delay to add, what if its enough of a delay in most situations but not all, so make it longer to compensate, but then the pushing of the 2nd VC will be delayed possibly noticably etc. etc.).
When the notification(s) fires I could look to see if a VC has been pushed and if so if its viewDidAppear: has been called yet and if not hold off processing the notification(s) until it has.
This is doable but a small bit of messing to kept track of if/what stage the VC push is at.
Is there a more elegant solution? I’d prefer to avoid having to add yet another queue to the app.
If there’s not really any alternatives, what are options for the delaying of processing of the notifications? Could they actually be rescheduled with the OS for example so that they will execute in the next run loop (which should give the chance for viewDidAppear: to execute)?
Or is it necessary to use navigationController:didShowViewController:animated: and inspect and process a notification queue within there?
Any other options?
Thanks
you can try this