夫特4 AFNetworking typealias转换错误

夫特4 AFNetworking typealias转换错误

问题描述:

我迁移到夫特4和I具有以下typealias:夫特4 AFNetworking typealias转换错误

typealias AFDataSuccess = (task: URLSessionDataTask, responseObject: Any?)

但我具有如图附加图像麻烦转换它:

enter image description here

+1

它会更容易使用_Alamofire_转换,IMO 。 – holex

你必须使用这样的:

manager.post(route.url, parameters: params, progress: nil, success: { (task: URLSessionDataTask, response: Any?) in 
    print(response) 
}) { (task: URLSessionDataTask, error: Error) in 
    print(error.localizedDescription) 
} 
+0

谢谢,这是方式 –

是@holex是利用Alamofire

0123绝对的权利,你应该使用Alamofire因为更好的方法在网络斯威夫特

这里是链接https://github.com/Alamofire/Alamofire

使用Alamofire。这是最好的迅速网络和使用像这个 - >

Alamofire.request("https://httpbin.org/get").responseJSON { response in 
print("Request: \(String(describing: response.request))") // original url request 
print("Response: \(String(describing: response.response))") // http url response 
print("Result: \(response.result)")       // response serialization result 

if let json = response.result.value { 
    print("JSON: \(json)") // serialized json response 
} 

if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) { 
    print("Data: \(utf8Text)") // original server data as UTF8 string 
} 

简单的方法}