asheyla asheyla - 2 months ago 111
iOS Question

Swift 3 warning for dispatch async

I have this code:

DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async {
let url = URL(string: itemImageURL )
let data = try? Data(contentsOf: url!)
if data != nil {
DispatchQueue.main.async{
cell.advImage!.image = UIImage(data: data!)
}
}
}


I get this warning in Swift 3:


'default' was deprecated in iOS 8.0: Use qos attributes instead


on the first line.

Haven't found yet a solution. Has anybody?

Answer

try qos: DispatchQoS.QoSClass.default instead of priority: DispatchQueue.GlobalQueuePriority.default

DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
            let url = URL(string: itemImageURL )
            let data = try? Data(contentsOf: url!)
            if data != nil {
                DispatchQueue.main.async{
                    cell.advImage!.image = UIImage(data: data!)
                }
            }
        }
Comments