O'Reilly logo

iOS Programming Cookbook by Hossam Ghareeb

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 Operation subclassing

Most often, operations that you need to perform are better encapsulated in a custom subclass of the Operation class. We have already worked with BlockOperation in the previous demo, but we saw a lot of redundancy in writing code and it's not customized. In this section, we will implement the same demo and see how we build a custom Operation class to perform the task that will be done concurrently.

How to do it...

To build a custom Operation class, perform the following steps:

  1. In our Xcode project, add a new Swift file with a class, named ImageDownloader, which extends the Operation class:

    How to do it...

  2. In the ImageDownloader.swift file, ...

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