A lightweight swift library for loading images and JSON
Add the pod to your Podfile:
pod 'IamLoader', :git => 'https://github.com/hjwlpjr/IamLoader.git'And then run:
pod installAfter installing the cocoapod into your project import IamLoader with
import IamLoaderLoad image using IamLoader is very easy with only one single line
IamLoaderImage.loadImage(urlString: url)Don't worry, Image Cache is handled automatically so no heavy request image data repeatly. By default IamLoader can cache up to 50 image and will start deleting old cache that is least used.
IamLoader has built-in multiple image shape option, just pass the parameter and ready to go
.resize(withSize: imageSize)
.makeShape(withShape: .round, radiusForRound: 8) // for rounded
.makeShape(withShape: .circle) // for circleUnder the hood IamLoaderRequest use built-in NSURLSession and Decodable protocol to fetch and decode JSON data with Swift 5 Result Type as completion handler
IamLoaderRequest.fetchData(apiUrl: apiUrl, type: .json) { (res: Result<T, RequestError>) in ... }IamLoader support for constructing query string using class/struct with decodable
struct Pagination: Decodable {
let pageSize: Int
let currentPage: Int
}
...
let params = Pagination(...)
IamLoaderRequest.fetchDataWithParams(apiUrl: apiUrl, parameter: params, type: .json) { (res: Result<T, RequestError>) in ... }
