GCD obtaining queue name/label

こ雲淡風輕ζ 提交于 2019-12-07 06:53:40

问题


How can I get the current queue name?

I mean queue label like com.example.myqueue.

In the Xcode 4 debugger I can see just _block_invoke_1.


回答1:


How about dispatch_queue_get_label?




回答2:


In Objective-C you can log the label of the current queue with:

NSLog(@"%s", dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));

In Swift (2.0):

print(String(UTF8String: dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL))!)


来源:https://stackoverflow.com/questions/5166711/gcd-obtaining-queue-name-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!