I’m building an iPhone app which gets updates from the web at regular time intervals and when the user is browsing through the apps data.
I have a class called updateManager which handles the updating process.
When the updating process is finished (0.1-3.0 seconds later) the data in my app could be changed but the user is still viewing the old (false) data. This causes big problems when the user is viewing a (drill-down)tableview and he selects a cell which data doesn’t exist anymore.
Is there a way to access the current view(controller) from another class and reload it’s (table)view? It is not possible to send the current view controller to the updateManager since the user could have changed view’s while the update is in progress
EDIT:
I looked at this post: Reload a tableView from the AppDelegate but i think the problem with the user switching views while updating is still there isn’t it?
Not sure that’s the best solution. You get a more decoupled design if you use the Observer pattern instead. Use
NSNotificationCenterto post a notification when the data changes. Then any view who is displaying data would subscribe to those notifications and can then reload the table upon such an event.