什么相当于“dispatch_apply”在Swift 3? [英] What is equivalent of "dispatch_apply" in Swift 3?

查看:514
本文介绍了什么相当于“dispatch_apply”在Swift 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在swift3中搜索相当于dispatch_apply的东西。请帮帮我

I have been searching for an equivalent of dispatch_apply in swift3. Help me please

转换

    let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_apply(2, queue) { (index)  in
    }


推荐答案

你还记得 dispatch_apply()吗?嗯,它仍然存在,并得到一个新的名字。从现在开始,您必须致电 concurrentPerform()

Do you still remember dispatch_apply(). Well, it's still there and got a new name. From now on you have to call concurrentPerform()

更改此

dispatch_apply(2, queue) { (index)  in
}

进入

DispatchQueue.concurrentPerform(iterations: 2) {
print("\($0). concurrentPerform")
}

这篇关于什么相当于“dispatch_apply”在Swift 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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