From f6ea85e507dd1ca29cf5cf7171efa96790170cf9 Mon Sep 17 00:00:00 2001 From: g4zeru Date: Mon, 14 Sep 2020 19:15:31 +0900 Subject: [PATCH] add public function --- ImageStore/Classes/ImageStore.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ImageStore/Classes/ImageStore.swift b/ImageStore/Classes/ImageStore.swift index f8b55dc..ed6c87a 100644 --- a/ImageStore/Classes/ImageStore.swift +++ b/ImageStore/Classes/ImageStore.swift @@ -74,6 +74,18 @@ public final class ImageStore: NSObject { cache.totalCostLimit = Int(self.config.cacheLimit) } + @discardableResult + public func load(_ url: URL, completion: @escaping (Result) -> Void) -> URLSessionDownloadTask? { + load(url, completion: { (image, error) in + if let image = image { + completion(.success(image)) + } else if let error = error { + completion(.failure(error)) + } + } + ) + } + @discardableResult public func load(_ url: URL, completion: ImageStoreCompletionHandler? = nil) -> URLSessionDownloadTask? { if let cachedImage: UIImage = cache.object(forKey: url.absoluteString as AnyObject) {