Defining concurrent custom operations

You may find there are occasions in which you want to manage the running of an operation yourself, which will mean not adding it to an operation queue. If that operation is to be synchronous, then there are no problems with that.

But if you want the code to run asynchronously, you have a bit more work to do, in that you must create a concurrent operation.

When doing this, we need to make sure we have a few things covered:

  • We need a custom init method to set the operation in a known state
  • We need to override the main method with our custom code
  • We need to ensure that the class complies with KVO, on which the operation framework depends

A concurrent operation will not complete until it issues its isFinished ...

Get Mastering macOS Programming 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.