/NSOperation-Swift

The playground file as to why we need Async NSOperation and how to create one

Primary LanguageSwift

This playground was created to be a companion playground to explain how to create an Asynchronous NSOperation. Below is the list of the different playground files and the Swift logic:

  • First playground page provides a simple GCD example.
  • Second playground page provides the basic scenario in which NSOperation is used.
  • Third playground page explains why provided NSOperation API does not work for executing asynchronous logic.
  • Fourth playground provides one of the ways to implement an asynchronous NSOperation API that can be subclassed to execute asynchronous logic.

The playground also has global Sources file. Here I have created a key-value observer in order to demo the KVO notifications that NSOperation fires. It is by the print statements in these notifications that I demo the different NSOperation behaviors

There is a lots of inline text explaining what the demo is about and a high level overview of the API in use.