Andrew Andrew - 3 months ago 8x
iOS Question

Get current dispatch queue?

I have a method which should support being called from any queue, and should expect to. It runs some code in a background thread itself, and then uses dispatch_get_main_queue when it returns a value to it's block argument. I don't want it to force it onto the main queue if it wasn't when it entered the method. Is there a way to get a pointer to the current dispatch queue?


You do have the option of "dispatch_get_current_queue()", however the iOS 6.1 SDK defines this API with these disclaimers:

"Recommended for debugging and logging purposes only:"


"This function is deprecated and will be removed in a future release.".

Here's another related question with some alternatives you can consider if you want code that's future-proof.