swift开源库swift学习iOS-swift

Swift网络框架封装

2017-02-25  本文已影响673人  fd320d65dbd8

GitHub传送门https://github.com/JonHory/JHNetwork

导航

<a id="介绍"></a> 介绍:

<a id="TODO"></a> TODO:

<a id="快速接入"></a>快速接入:

pod 'Alamofire', '~> 4.3'
pod 'SwiftyJSON', '~> 3.1.4'  

<a id="代码示例"></a>代码示例:

JHNetwork.shared.shoulObtainLocalWhenUnconnected(shouldObtain: true)
//刷新缓存
getForJSON(url:finished:)
//可带参数,刷新缓存
getForJSON(url:parameters:finished:)
//可设置是否刷新缓存
getForJSON(url:refreshCache:parameters:finished:)
getNoCacheForJSON(url:finished:)
getNoCacheForJSON(url:parameters:finished:)
getNoCacheForJSON(url:refreshCache:parameters:finished:)
postForJSON(url:finished:)
postForJSON(url:parameters:finished:)
postForJSON(url:refreshCache:parameters:finished:)
postNoCacheForJSON(url:finished:)
postNoCacheForJSON(url:parameters:finished:)
postNoCacheForJSON(url:refreshCache:parameters:finished:)
/// 请求JSON数据最底层
///
/// - Parameters:
///   - methodType: GET/POST
///   - urlStr: 接口
///   - refreshCache: 是否刷新缓存,如果为false则返回缓存
///   - isCache: 是否缓存
///   - parameters: 参数字典
///   - finished: 回调
requestJSON(methodType:urlStr:refreshCache:isCache:parameters:finished:)

getCacheForJSON(url:parameters:finished:)
totalCacheSize()
clearCaches()

灵感

联系我

上一篇下一篇

猜你喜欢

热点阅读