IncredibleNetworkManager
示例
要运行示例项目,请克隆仓库,并首先从Example目录运行pod install
要求
语言 | 最低iOS目标 | 最低Xcode版本 | |
---|---|---|---|
IQKeyboardManagerSwift | Swift | iOS 8.0 | Xcode 9.0 |
示例项目 | Xcode 9.0 |
安装
IncredibleNetworkManager可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中
pod 'IncredibleNetworkManager'
使用方法
要使用该库,请使用以下命令在AppDelegate中初始化
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
NetworkManager.initializeNetworkManager()
return true
}
}
要向服务器请求数据,使用以下方法
NetworkManager.shared.performRequest(_ urlString: String?,
method: URLMethod? = .GET,
bodyData: Data? = nil,
headerValues: [[String]]? = nil,
shouldCache: Bool = false,
completion:@escaping (_ data: Data?) -> Void,
timeoutAfter timeout: TimeInterval = 120,
onTimeout: (()->Void)? = nil) -> URLSessionDataTask?
要使用缓存加载图片,使用以下方法
imageView.setImage(<#T##url: String?##String?#>, thumbnailUrl: <#T##String?#>, placeholder: <#T##UIImage?#>, animated: <#T##Bool#>, completion: <#T##((UIImage?) -> Void)?##((UIImage?) -> Void)?##(UIImage?) -> Void#>)
作者
Fabio Gustavo Hoffmann, [email protected]
许可
IncredibleNetworkManager 适用于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。
版本
0.1.2
Fixed load image completion
0.1.1
Initial Version