Using Operations in your apps

Let's take a deep dive into Operations and refactor the background fetch code from the MustC app to make it use Operations. To do this, you will create two Operation subclasses: one that fetches data and updates a movie object, and one that calls the completion handler once all other operations are complete.

The setup will have a single OperationQueue that will execute all of the instances of the fetch Operation subclass and a single operation that calls the background fetch completion handler. The completion operation will have all of the fetch operations as its dependencies, so it's automatically executed when all fetch operations are completed.

Whenever you create an OperationQueue instance, you can specify ...

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.