本文介绍了Alamofire:完成错误 - 代码:-1001的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这样的代码:
import Foundation
import Alamofire
struct Request {
var alamoFireManager : SessionManager?
init() {
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 20
configuration.requestCachePolicy = .useProtocolCachePolicy
alamoFireManager = Alamofire.SessionManager(configuration: configuration)
}
func sendRequest() {
alamoFireManager?.request(url,method: method, parameters: body, encoding: JSONEncoding.default,headers: headers).responseJSON { response in
}
}
}
推荐答案
SessionManager
对我无效。最好在 Alamofire 中使用这样的代码:
SessionManager
not works for me correctly. It's better to using code like this in Alamofire:
let request = URLRequest(url: url)
request.httpMethod = "GET"
//Some configuration
Alamofire.request(request).responseJSON {
response in
}
这篇关于Alamofire:完成错误 - 代码:-1001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!