Swift 3 warning for dispatch async

前端 未结 4 457
灰色年华
灰色年华 2021-02-03 19:57

I have this code:

DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async {
                let url = URL(string: itemImageURL )
                 


        
4条回答
  •  再見小時候
    2021-02-03 20:58

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

提交回复
热议问题