MQZHot / DaisyNet

Alamofire与Cache封装 , 更容易存储请求数据
MIT License
379 stars 65 forks source link
alamofire cache download json network request swift

DaisyNet

AlamofireCache的封装实现对网络数据的缓存,可以存储JSON,String,Data.

使用

/// 缓存标识
let identifier = "home"

/// 网络请求
DaisyNet.request(urlStr, params: params).cacheIdentifier(identifier).responseString(queue: .main) { result in
    switch result {
    case .success(let string):
        self.textView.text = string
        print(Thread.current)
    case .failure(let error):
        print(error)
    }
}
/// 缓存标识
let identifier = "home"

/// 读取缓存
let cacheString = DaisyNet.cacheString(with: identifier)
let cacheData = DaisyNet.cacheData(with: identifier)
let cacheJson = DaisyNet.cacheJson(with: identifier)

Install

1.pod 'DaisyNet'

2.pod install / pod update

Author

LICENSE

DaisyNet is released under the MIT license. See LICENSE for details.