我正在使用 Swift 3 DispatchGroup
等待多个异步操作完成(根据 this answer,它运行完美且符合预期。
有没有办法检查已经输入了多少操作,比如 dispatchGroup.count
或类似的东西?
最佳答案
您可以在调试说明中看到进入组的次数:
OS_dispatch_group: group[0x60000221d950] = { xref = 3, ref = 3, count = 2, gen = 0, waiters = 0, notifs = 1 }
并从中提取 int 值:
let count = dispatchGroup.debugDescription.components(separatedBy: ",").filter({$0.contains("count")}).first?.components(separatedBy: CharacterSet.decimalDigits.inverted).compactMap{Int($0)}.first
关于swift3 - 调度组 : check how many "entered",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45610271/