2017-10-11 42 views

回答

0

你必须使用这样的:

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

谢谢,这是方式 –

0

使用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 
} 

简单的方法}