What is equivalent of “dispatch_apply” in Swift 3?

2019-02-24 06:36发布

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
    }

标签: ios swift swift3
1条回答
放我归山
2楼-- · 2019-02-24 07:16

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")
}
查看更多
登录 后发表回答