iosgrand-central-dispatchnsoperationqueuelibdispatch

Interoperability of NSOperationQueue and GCD


I am building a library for which I'd like the processing to happen in a single serial queue. Some of the APIs I use take NSOperationQueue (e.g. NSURLSession) and some take dispatch_queue_t (e.g. CBCentralManager).

How do I specify the NSOperationQueue and dispatch_queue_t values so that they point to the same queue? Or are the two not interoperable and what I'm trying to do is not possible and/or advisable?


Solution

  • Create a dispatch_queue_t in the second case; assign it to the underlyingQueue of an NSOperationQueue for the first. NSOperationQueues sit atop dispatch queues; since iOS 8 you can specify the queue.