Network
使用方式
发送请求
import Network
Network.request("https://httpbin.org/get").build()
Network.request("https://httpbin.org/get").query(["foo": "bar"]).build()
Network.request("https://httpbin.org/get").headers(["Custom-Content-Type": "application/json; encrypted=1"]).build()
Network.request("https://httpbin.org/post").post(["foo": "bar"]).encoding(.URLEncodedInURL).build()
Network.request("https://httpbin.org/post").post(["foo": "bar"]).encoding(.JSON).retry(1).build()
Network.request("https://httpbin.org/post").post(["foo": "bar"]).encoding(.JSON).priority(Network.Priority.Low).build()
// Please take a look at Network.swift for more configuration
处理响应
Network.request("https://httpbin.org/get").build()?.responseJSON { request, response, responseValue, error in
}
let (response, responseData, error) = Network.request("https://httpbin.org/post").query(["foo": "bar"]).post(["encode": "json"]).encoding(.JSON).syncResponseJSON()
需求
安装
网络通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中
pod "Network"
作者
Suen, [email protected]
许可证
遵循MIT许可证。有关更多信息,请参阅LICENSE文件。