【问题标题】:What is equivalent of "dispatch_apply" in Swift 3?Swift 3 中的“dispatch_apply”等价物是什么?
【发布时间】:2016-09-20 09:15:23
【问题描述】:

我一直在 swift3 中寻找类似 dispatch_apply 的东西。请帮帮我

转换

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

【问题讨论】:

  • DispatchQueue.concurrentPerform(iterations:

标签: ios swift swift3


【解决方案1】:

你还记得 dispatch_apply()。好吧,它还在那里,并有了一个新名字。从现在开始你必须调用 concurrentPerform()

改一下

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

进入

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

【讨论】:

    猜你喜欢
    • 2016-12-13
    • 2014-09-24
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多