我在整个项目中都使用了Alamofire:
Alamofire.request("http://my.api.com", method: .get, parameters: ["some": "thing"], encoding: URLEncoding.default, headers: myHeaders)
是否可以快速设置我上述所有请求的超时时间?我没有运气就尝试了以下内容
Alamofire.SessionManager.default.session.configuration.timeoutIntervalForRequest = 10
Alamofire.SessionManager.default.session.configuration.timeoutIntervalForResource = 10
答案 0 :(得分:0)
let configuration = URLSessionConfiguration.default configuration.timeoutIntervalForRequest = 10 let manager = Alamofire.SessionManager(configuration: configuration)