From 36124261874b1a7d7be790df6bb07d2b2512e22f Mon Sep 17 00:00:00 2001 From: Vitaliy Tim Date: Tue, 2 Mar 2021 14:22:54 +0200 Subject: [PATCH 1/2] Updating the .image property of a LightboxImage instance after Lightbox has downloaded an image via URL (again) --- Source/LightboxImage.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/LightboxImage.swift b/Source/LightboxImage.swift index 84aac952..6f939e6f 100644 --- a/Source/LightboxImage.swift +++ b/Source/LightboxImage.swift @@ -38,7 +38,10 @@ open class LightboxImage { imageView.image = image completion?(image) } else if let imageURL = imageURL { - LightboxConfig.loadImage(imageView, imageURL, completion) + LightboxConfig.loadImage(imageView, imageURL) { downloadedImage in + self.image = downloadedImage + completion?(downloadedImage) + } } else if let imageClosure = imageClosure { let img = imageClosure() imageView.image = img From ddfe6392e3da1a7a0eee3bcc1211d2e3e08ad8ec Mon Sep 17 00:00:00 2001 From: Vitaliy Tim Date: Tue, 2 Mar 2021 15:34:40 +0200 Subject: [PATCH 2/2] made self to be weak --- Source/LightboxImage.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/LightboxImage.swift b/Source/LightboxImage.swift index 6f939e6f..9885f60a 100644 --- a/Source/LightboxImage.swift +++ b/Source/LightboxImage.swift @@ -38,8 +38,8 @@ open class LightboxImage { imageView.image = image completion?(image) } else if let imageURL = imageURL { - LightboxConfig.loadImage(imageView, imageURL) { downloadedImage in - self.image = downloadedImage + LightboxConfig.loadImage(imageView, imageURL) { [weak self] downloadedImage in + self?.image = downloadedImage completion?(downloadedImage) } } else if let imageClosure = imageClosure {