문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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 ;)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top