Skip to content

nbpapps/ImageLoading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageLoading

A Swift Package for loading remote images.

Image loading and canceling is handled by extentions on UIImageView.

Includes caches for storing the key-value pairs of the images, the running tasks and the IDs assigned for each image view.

I'd like to thank Donny Wals for his great post which was the insperation for this Swift Package

Using it in your project.

- In Xcode navigate to File -> Swift Packages -> Add Package Dependency…
Enter this URL - https://github.com/nbpapps/ImageLoading 

Setting an image in an ImageView:

import UIKit
import ImageLoading

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? UITableViewCell, let url = URL(string: "https://www.images.com/myImage") else {
            preconditionFailure()
        }
        cell.imageView?.loadImage(at: url)
    }

Cancel image loading:

import UIKit
import ImageLoading

class MyCollectionViewCell: UICollectionViewCell {
    override func prepareForReuse() {
        super.prepareForReuse()
        myImageView.cancelImageLoad()
        myImageView.image = nil
    }
}

About

A Swift Package for loading remote images

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages