【问题标题】:alternative to QOS_CLASS_UTILITY on ios7 using swift使用 swift 在 ios7 上替代 QOS_CLASS_UTILITY
【发布时间】:2016-02-07 11:33:21
【问题描述】:

我在 dispatch_async 中使用 QOS_CLASS_UTILITY 来执行一些异步操作。示例代码如下:

dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_UTILITY.value), 0)) {
                var ip = "163.289.2." + "\(i)"
                let foundThisOne = Ping.getIPAddress(ip)

                dispatch_async(serialQueue) {
                    if !resultFound {
                        resultFound = foundThisOne
                        numProcessed++
                        if resultFound {
                            completion(existingIP:ip)
                        } else if numProcessed == 256 {
                            completion(existingIP: nil)
                        }
                    }
                }
            }
        }

但是“QOS_CLASS_UTILITY”在 iOS8 以后可用,现在我也需要在 iOS7 上支持相同的逻辑。那么有什么更好的选择 使用 swift 在 iOS7 上运行的 QOS_CLASS_UTILITY。

【问题讨论】:

    标签: ios iphone swift ios7 dispatch-async


    【解决方案1】:

    根据documentation(请参阅全局并发队列)我想说您可以将其替换为:

    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-02
      • 1970-01-01
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多