YaroslavZhurbilo
6/6/2017 - 10:13 AM

Generated by Xgist (https://github.com/Bunn/Xgist) at 06. Jun.2017, 13:13:38

Generated by Xgist (https://github.com/Bunn/Xgist) at 06. Jun.2017, 13:13:38

    func updateUI(partyRock: PartyRock) {
        videoTitle.text = partyRock.videoTitle
        if let url = URL(string: partyRock.imageURL) {
            
            // Async
            DispatchQueue.global().async {
                do {
                    let data = try Data(contentsOf: url)
                        DispatchQueue.main.async {
                            self.videoPreviewImage.image = UIImage(data: data)
                        }
                    } catch {
                        print(error.localizedDescription)
                    }
            }
            
            // Async by Mark Price
            DispatchQueue.global().async {
                do {
                    let data = try Data(contentsOf: url)
                    DispatchQueue.global().sync {
                        self.videoPreviewImage.image = UIImage(data: data)
                    }
                } catch {
                    print(error.localizedDescription)
                }
            }
            
            // Sync
            do {
                let data = try Data(contentsOf: url)
                videoPreviewImage.image = UIImage(data: data)
                print("ok")
            } catch {
                print(error.localizedDescription)
            }
        }
    }