Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top