Swift 2 to 3 Migration dispatch_get_global_queue [

2020-02-13 04:12发布

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

2条回答
够拽才男人
2楼-- · 2020-02-13 05:01

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

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

查看更多
不美不萌又怎样
3楼-- · 2020-02-13 05:13

Try this it will work.

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

    DispatchQueue.main.async {

    }
})

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

查看更多
登录 后发表回答