Swift 3:无法将'int'类型的值转换为预期的参数类型'DispatchQueue.GlobalQueuePriority' [英] Swift 3: Can not convert value of type 'int' to expected argument type 'DispatchQueue.GlobalQueuePriority'

查看:168
本文介绍了Swift 3:无法将'int'类型的值转换为预期的参数类型'DispatchQueue.GlobalQueuePriority'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 3.0:接收错误无法将类型'int'的值转换为预期参数类型'DispatchQueue.GlobalQueuePriority'关于创建调度异步queue

Swift 3.0: Receiving error Can not convert value of type 'int' to expected argument type 'DispatchQueue.GlobalQueuePriority' on creating dispatch async queue

DispatchQueue.global(priority: 0).async(execute: { () -> Void in

})


推荐答案

警告,不推荐使用在iOS 8中,请参阅下面的最新信息



DispatchQueue.global 需要 DispatchQueue.GlobalQueuePriority enum,即:

WARNING, This is deprecated in iOS 8, see below for latest

DispatchQueue.global expects the DispatchQueue.GlobalQueuePriority enum, which is:


  • high

  • default


  • 背景

  • high
  • default
  • low
  • background

所以在你的情况下,你只需写:

So in your case, you just write:

DispatchQueue.global(priority: .background).async(execute: { () -> Void in

})

如果您想要最低优先级。

If you want the lowest priority.

快速检查显示, DispatchQueue.global(priority:_)在iOS 8中已弃用。

A quick check reveals, that DispatchQueue.global(priority:_) is deprecated in iOS 8.

DispatchQueue.global(qos: .background).async {

}

这为您提供了更多选择:

Which gives you even more options to choose from:


  • 背景

  • 实用工具

  • 默认

  • userInitiated

  • userInteractive

  • 未指定

  • background
  • utility
  • default
  • userInitiated
  • userInteractive
  • unspecified

这篇关于Swift 3:无法将'int'类型的值转换为预期的参数类型'DispatchQueue.GlobalQueuePriority'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆