Operation Queue vs Dispatch Queue for iOS Application

Lopper picture Lopper · Aug 16, 2011 · Viewed 28.5k times · Source
  1. What are the differences between Operation Queue and Dispatch Queue?
  2. Under what circumstances will it be more appropriate to use each?

Answer

omz picture omz · Aug 16, 2011

OperationQueue internally uses Grand Central Dispatch and on iOS.

OperationQueue gives you a lot more control over how your operations are executed. You can define dependencies between individual operations for example, which isn't possible with plain GCD queues. It is also possible to cancel operations that have been enqueued in an OperationQueue (as far as the operations support it). When you enqueue a block in a GCD dispatch queue, it will definitely be executed at some point.

To sum it up, OperationQueue can be more suitable for long-running operations that may need to be cancelled or have complex dependencies. GCD dispatch queues are better for short tasks that should have minimum performance and memory overhead.