Skip to content

hjwlpjr/IamLoader

Repository files navigation

IamLoader

A lightweight swift library for loading images and JSON

CocoaPods

Add the pod to your Podfile:

pod 'IamLoader', :git => 'https://github.com/hjwlpjr/IamLoader.git'

And then run:

pod install

After installing the cocoapod into your project import IamLoader with

import IamLoader

How to use IamLoader Image

Load image using IamLoader is very easy with only one single line

IamLoaderImage.loadImage(urlString: url)

Image Cache

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.























What other Feature IamLoaderImage support?

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 circle

Fetch JSON Data

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

string interpolation for query string? = NO

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

About

A lightweight swift library for loading images and JSON

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •