Pregunta

On iOS/Objective-C, given an executing NSBlockOperation, is it possible to determine which queue the operation is associated with? Determining if one is on the main thread is pretty obvious, but what about operations in the background?

¿Fue útil?

Solución

How about

[NSOperationQueue currentQueue];

From the docs:

You can use this method from within a running operation object to get a reference to the operation queue that started it. Calling this method from outside the context of a running operation typically results in nil being returned.

Otros consejos

There is a DEPRECATED method: dispatch_get_current_queue()

BUT apple really doesn't like it because it isn't safe or may lead to deadlocks or .. I didn't fully get the issue ;)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top