In an iOS application, I have some local sqlite db tables that I want to update/refresh either with a specific frequency or just once according to remote API JSON updates. For the moment I start a timer or trigger a refresh in a specific View Controller. I observe notifications internally in each view controller that deal with a specific model and I use AFNetworking. Of course, if I switch to different view controller, then the observing of notifications (of previous MVC) might not be reliable. What I am thinking is to create a global event management/observer mechanism that I expect that it should run in a different thread (concurrent/active object) that will be always active and will be the centre of handling of the observed notifications (notifications can be considered as a solution that can be changed to something else if necessary to achieve my goal). What are the best practices or design patterns that can be used to deal with this issue i.e. to have a centre of API sync with local db?
Aucun commentaire:
Enregistrer un commentaire