Swift 3 warning for dispatch async

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

    Below code is tested for Swift 3.0 on Xcode 8.2.1

    DispatchQueue.global(qos: .background).async {
                let img2 = Downloader.downloadImageWithURL(imageURLs[1])
    
                // Background Thread
                DispatchQueue.main.async {
    
                    // Run UI Updates
                    self.imageView2.image = img2
                }
            }
    

    where property of QoS are :

    background, utility, `default`, userInitiated, userInteractive and unspecified
    

    Refer this apple document for more details.

提交回复
热议问题