Swift 3 warning for dispatch async Swift 3 warning for dispatch async ios ios

Swift 3 warning for dispatch async


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!)                }            }        }


Instead of using priority parameter:

DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async { // ...}

use qos parameter that uses a different enum DispatchQoS.QoSClass.default but you can also use its enum value as just .default:

DispatchQueue.global(qos: .default).async { // ...}

Swift 3 has brought many changes on GCD(Grand Central Dispatch).


If you're creating a property using the Dispatch Framework and updating the UI with some animation within a function it might look something like this.

let queue = DispatchQueue.global(qos: DispatchQoS.QoSClass.default)    // dispatch_after says that it will send this animation every nsec    queue.asyncAfter(deadline: when) {        DispatchQueue.main.async(execute: {            self.animate(withDuration: 0.5, animations: {                self.image.setWidth(35)                self.image.setHeight(35)            })        })    }


matomo