Swift 3: Can not convert value of type 'int' to expected argument type 'DispatchQueue.GlobalQueuePriority'

前端 未结 1 1955
心在旅途
心在旅途 2021-01-03 20:16

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

相关标签:
1条回答
  • 2021-01-03 20:19

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

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

    • 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.

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

    Latest solution:

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

    Which gives you even more options to choose from:

    • background
    • utility
    • default
    • userInitiated
    • userInteractive
    • unspecified
    0 讨论(0)
提交回复
热议问题