Updating the movies

The process of updating movies is a strange one. As you saw earlier, network requests are performed asynchronously, which means that you can't rely on the network request being finished by the time a function is finished executing. Because of this, a callback is used. The callback is then called when the network request is done.

But what happens if you need to wait for multiple requests? How do you know that all requests to update movies have been completed? Since the movie database doesn't allow developers to fetch multiple movies at once, a bunch of requests must be made. When all of these requests are complete, the background fetch completionHandler should be called with the result of the operation.

To achieve this, ...

Get Mastering iOS 12 Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.