What is equivalent of “dispatch_apply” in Swift 3?

不想你离开。 提交于 2019-12-23 11:49:17

问题


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

convert

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

回答1:


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

change this

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

into

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


来源:https://stackoverflow.com/questions/39590128/what-is-equivalent-of-dispatch-apply-in-swift-3

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