I want to do the following:
1. display loader
2. download database update and reload data
3. hide loader
My idea is to send notifications at the begining and at the end of Database's update method to the main view controller, so that the view controller displays and hides the loader.
I am worried about the control flow. Do I have any guarantee that the view controller will receive the notification and display the loader before the Database's update method proceeds?
The notifications are queued in the system, so there's no guarantee it's going to be instantly. Anyway, they are usually quite fast, for sure faster than the work on the database.
If you want to be 100% sure, just set a flag somewhere and when you receive the notification, check that the databases is reloaded.
Anyway, I'm just thinking that even if the notification is received after the reload of the database, because the notification are queued, the hide loader notification will come right after the first one, so there would be nothing to worry about.