Handles getting an image from the network and caches image to caches directory or documents.
To install copy this github url
https://github.com/alexpaul/ImageKit
Navigate to Xcode and do the following:
Click Next then Finish. At this point the package should have been installed successfully 🥳
By default images are cached to avoid making additional network requests. Cache is purged by iOS as needed. If you need to permanently save images you can override the the default directory from default argument .cachesDirectory to .documentsDirectory as follows getImage(with: imageURL, writeTo: .documentsDirectory))
imageView.getImage(with: imageURL) { (result) in
switch result {
case .failure:
DispatchQueue.main.async {
self.imageView.image = UIImage(systemName: "exclamationmark.triangle.fill")
}
case .success(let image):
DispatchQueue.main.async {
self.imageView.image = image
}
}
}
ImageKit is released under the MIT license. See LICENSE for details.
link |
Stars: 9 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics