From 3b31cb175a26b1a123b1590c137c51d3061361fe Mon Sep 17 00:00:00 2001 From: noblakit Date: Sun, 16 Jul 2017 10:24:34 +0700 Subject: [PATCH] : hammer: Update main queue return completion --- PhotoCollectionView/PhotoCache.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PhotoCollectionView/PhotoCache.swift b/PhotoCollectionView/PhotoCache.swift index c337a5a..41ce4dc 100644 --- a/PhotoCollectionView/PhotoCache.swift +++ b/PhotoCollectionView/PhotoCache.swift @@ -28,7 +28,9 @@ open class PhotoCache { if let workItem = workItems.object(forKey: urlString as NSString) { workItem.notify(queue: queue, execute: { [weak self] in if let image = self?.images.object(forKey: urlString as NSString) { - completion(image) + DispatchQueue.main.async { + completion(image) + } } }) return @@ -47,7 +49,9 @@ open class PhotoCache { } } } catch ( _) { - completion(nil) + DispatchQueue.main.async { + completion(nil) + } } } workItems.setObject(workItem, forKey: urlString as NSString)