什么相当于Swift 3中的"dispatch_apply"?

ven*_*nky 5 ios swift swift3

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

兑换

    let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_apply(2, queue) { (index)  in
    }
Run Code Online (Sandbox Code Playgroud)

Anb*_*hik 20

你还记得dispatch_apply() .嗯,它仍然在那里,并得到一个新的名字.从现在开始,你必须调用concurrentPerform()

改变这一点

dispatch_apply(2, queue) { (index)  in
}
Run Code Online (Sandbox Code Playgroud)

DispatchQueue.concurrentPerform(iterations: 2) {
print("\($0). concurrentPerform")
}
Run Code Online (Sandbox Code Playgroud)