Swiftpack.co - alexpaul/ImageKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by alexpaul.
alexpaul/ImageKit 1.0.5
Handles getting an image from the network and caches image to caches directory or documents.
⭐️ 9
🕓 4 years ago
iOS
.package(url: "https://github.com/alexpaul/ImageKit.git", from: "1.0.5")

ImageKit

Handles getting an image from the network and caches image to caches directory or documents.

Version Releases

Requirements

  • Xcode 10.2+
  • Swift 5.0+

Swift Package Installation

To install copy this github url https://github.com/alexpaul/ImageKit
Navigate to Xcode and do the following:

  • select File -> Swift Packages -> Add Package Dependency
  • paste the copied url above into the search field in the presented dialog
  • In the Choose Package Options select the Version Rules option (default option). Version rules will update Swift packages based on their relesase versions e.g 1.0.1

Click Next then Finish. At this point the package should have been installed successfully 🥳

Swift Package Dependencies

Usage

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
    }
  }
}

License

ImageKit is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 9
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics