Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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  }) 
like image 272
Kiran Jasvanee Avatar asked Sep 22 '16 12:09

Kiran Jasvanee


1 Answers

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
like image 78
Dejan Skledar Avatar answered Sep 22 '22 18:09

Dejan Skledar