Swift 3 warning for dispatch async

前端 未结 4 445
灰色年华
灰色年华 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:57

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

提交回复
热议问题