O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Operations in your apps

Let's take a deep dive into Operations and refactor the background fetch code from the FamilyMovies app so it uses Operations. To do this, we're going to create two operation subclasses: One that fetches data and updates the movie object, and one that calls the completion handler.

Our setup will use a single OperationQueue onto which we push all of the instances of our fetch operation subclass, and one operation that calls the background fetch completion handler. The completion operation will have all of the fetch operations as its dependencies.

Whenever you create an OperationQueue instance, you can specify the amount of concurrent Operations that can be executed on the queue. If you set this to zero, the

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required