diff --git a/Tusker/Caching/ImageCache.swift b/Tusker/Caching/ImageCache.swift index 38f79435..2441b5e6 100644 --- a/Tusker/Caching/ImageCache.swift +++ b/Tusker/Caching/ImageCache.swift @@ -42,13 +42,18 @@ class ImageCache { // of the state (unknown/exists/does not exist) of whether or not objects exist on disk so that the slow, disk I/O // path can be avoided most of the time let entry = try? cache.get(key) { - backgroundQueue.async { - completion?(entry.data, entry.image) + if let completion = completion { + backgroundQueue.async { + completion(entry.data, entry.image) + } } return nil } else { - if let completion = completion, let group = groups[url] { - return group.addCallback(completion) + if let group = groups[url] { + if let completion = completion { + return group.addCallback(completion) + } + return nil } else { let group = RequestGroup(url: url) { (data, image) in if let data = data {