CachedRequester 1.0.2

CachedRequester 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Milad Nozari.



CachedRequester

Simple, light-weight network requester with auto-purging in-memory cache.

Usage

If you’re not comfortable with the default configurations, first configure the shared instance of the library in your AppDelegate.swift

CachedRequester.sharedInstance.autostart = true // default value
CachedRequester.sharedInstance.inMemoryCacheSizeLimit = 200 * 1024 * 1024 // 200 MiB, the default value
CachedRequester.sharedInstance.inMemoryCacheSizeLimitAfterPurge = 150 * 1024 * 1024 // 150 MiB, the default value

Everywhere else:

import CachedRequester
...

let url = URL(string: "url_to_resource")!
let task = Requester.sharedInstance.newTask(url: url, completionHandler: { (data, error) in
  guard error = nil, let data = data else {
    // do something with the error
    return
  }
  
  // do something with the data
  let image = UIImage(data: data)
  // or
  let json = JSONSerialization.jsonObject(with: data, options: .allowFragments)
  // or ...
}) { (progress) in
  self.progressbar.progress = Float(progress)
}