Imagine your app has to run a series of nice web service calls. These could be for a set-up task, for example - when your app launches it may need to get various bits of configuration information from a server. This could involve hitting several endpoints.
You want to call a single method to kick this process off, and have a completion block run when it has finished. The web services don’t depend on each other. How can this be done?
There’s a horrible way: start each service from the completion block of the previous one, and when the last one is done, call your overall completion block.
The nice way to do this is by using dispatch groups. A dispatch group monitors work that has been added to it, and it will know when that work is done.
Your new post is loading...