我用这个代码.
原文链接:https://www.f2er.com/swift/319217.htmlvar apiPath : String = "/api/list/" let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.timeoutIntervalForRequest = 60 let manager = Alamofire.Manager(configuration: configuration) manager.session.configuration.HTTPAdditionalHeaders = ["_token" : self._token] manager.request(.GET,self._host + self._url + apiPath,parameters: nil) .responseSwiftyJSON ({ (request,response,resultJson,error) in if (resultJson["Success"]) { //get list success } else { println("request : \(request)") println("response : \(response)") println("resultJson : \(resultJson)") println("error : \(error)") } })
我遇到了一些问题
Alamofire版本1.2.1:没问题
Alamofire版本1.2.2& 1.2.3:
request : { URL: https://test.com/api/list/ } response : nil resultJson : null
error : Optional(Error Domain=NSURLErrorDomain Code=-999 “cancelled”
UserInfo=0x7feb92c434f0 {NSErrorFailingURLKey=https
://test.com/api/list/,NSLocalizedDescription=cancelled,
NSErrorFailingURLStringKey=http s://test.com/api/list/})