From 24d013d5a09451343e03c086a106f8c3971510d1 Mon Sep 17 00:00:00 2001 From: rpekarek Date: Fri, 8 Nov 2019 11:17:40 -0700 Subject: [PATCH] Fixed NukeIntegration and README --- README.md | 2 +- Source/Integrations/NukeIntegration.swift | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d138ace..fa855c6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ While AXPhotoViewer has many configurable properties on each of its modules, it ```swift let dataSource = AXPhotosDataSource(photos: self.photos) -let photosViewController = PhotosViewController(dataSource: dataSource) +let photosViewController = AXPhotosViewController(dataSource: dataSource) self.present(photosViewController, animated: true) ``` diff --git a/Source/Integrations/NukeIntegration.swift b/Source/Integrations/NukeIntegration.swift index c0ee0d7..b5c7634 100644 --- a/Source/Integrations/NukeIntegration.swift +++ b/Source/Integrations/NukeIntegration.swift @@ -33,24 +33,26 @@ class NukeIntegration: NSObject, AXNetworkIntegrationProtocol { } } - let completion: ImageTask.Completion = { [weak self] (response, error) in + let completion: ImageTask.Completion = { [weak self] (result) in guard let `self` = self else { return } self.retrieveImageTasks.removeObject(forKey: photo) - - if let imageData = response?.image.animatedImageData { + switch result { + case let .success(response): + if let imageData = response.image.animatedImageData { photo.imageData = imageData AXDispatchUtils.executeInBackground { [weak self] in guard let `self` = self else { return } self.delegate?.networkIntegration(self, loadDidFinishWith: photo) } - } else if let image = response?.image { - photo.image = image + } else { + photo.image = response.image AXDispatchUtils.executeInBackground { [weak self] in guard let `self` = self else { return } self.delegate?.networkIntegration(self, loadDidFinishWith: photo) } - } else { + } + case .failure: let error = NSError( domain: AXNetworkIntegrationErrorDomain, code: AXNetworkIntegrationFailedToLoadErrorCode,