GCD or NSOperation?

You have now seen two different ways of architecting your code to support task-oriented parallelism, NSOperation and Grand Central Dispatch.

With GCD, the code for a particular operation tends to be concentrated in one place. You have a block that does work and then puts blocks onto other queues to do other work – the whole layers of an onion thing. GCD is very fast. There is little baggage associated with it. There is no reliance on KVO. GCD calls tend to be more ad-hoc and disposable, I’ll just put this here to run this on the main queue kinds of things. Plus, it is easier to copy and paste and create similar blocks doing the same work.

NSOperation tends to have the code more spread around. The code implementing an ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide 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.