Swift 2 到 3 迁移 dispatch_get_global_queue [英] Swift 2 to 3 Migration dispatch_get_global_queue

查看:66
本文介绍了Swift 2 到 3 迁移 dispatch_get_global_queue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我一直试图将其从 swift 2 转换为 swift 3.这是我目前所拥有的.

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

我收到一条错误消息,提示无法使用类型为 (int,int) 的参数列表调用全局".我知道全局队列需要这个,除非他们在 swift 3 中更改它?在 Swift 3 中执行全局队列的正确方法是什么?

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?

以前的 Swift 2 等效

Previous Swift 2 Equivlent

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

推荐答案

试试这个就行了.

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

    DispatchQueue.main.async {

    }
})

如果您仍然需要任何帮助,请随时在这里询问.

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

这篇关于Swift 2 到 3 迁移 dispatch_get_global_queue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆