Swift 2 to 3 Migration dispatch_get_global_queue [duplicate]

五迷三道 提交于 2019-12-18 07:23:56

问题


I have the following code that I've been trying to translate into swift 3 from swift 2. Here is what I have so far.

DispatchQueue.async(group: DispatchQueue.global(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),execute: {
            self.controllerDelegate?.codeToRun(progressWindowViewController: self)
        })

I am getting an error that says Cannot invoke 'global' with an argument list of type (int,int). I know that the global queue needs this though unless they changed it in swift 3? What is the correct way to do global queues in Swift 3?

Previous Swift 2 Equivlent

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),{
            self.controllerDelegate?.codeToRun(self)
        })

回答1:


Try this it will work.

DispatchQueue.global(qos: .background).async {

    DispatchQueue.main.async {

    }
})

If you still need any help feel free to ask here.




回答2:


Actually, a closer and simpler approach to your question would be:

DispatchQueue.global(qos: .default).async { ... }



来源:https://stackoverflow.com/questions/39744291/swift-2-to-3-migration-dispatch-get-global-queue

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