TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Matteo Crippa.
CacheManager is a swift local caching library built on top of Realm. Used with Moya it easily helps you to cache remote data from json.
You have simple to build an Object realm class and then create you ObjectManager using CacheManager.
CacheManager will allows you to:
pod 'CacheManager', '0.0.3'
import CacheManager
import Foundation
class MyModelManager: CacheManager<MyModel> {
private let net = Net()
override func getRemoteItems(completion: (error: NSError?) -> ()) {
net.listProductsByCategory(catName) { (prods, error) in
if (error != nil) {
print(error)
completion(error: error)
} else {
print("Models stored locally")
super.itemAddFromArray(prods!)
completion(error: nil)
}
}
}
}
This examples makes use of Moya style to retrieve items from remote, you are free to user your favorite method.
getRemoteItems Force items to be updated from remote
count Returns the number of items cached locally
itemAt (Optionally) returns an item at defined index