Swift 3 warning for dispatch async

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

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

提交回复
热议问题