Is it possible to add timeout handler for Alamofire request?
In my project I use Alamofire this way:
init() {
let configuration = NSURLSessionCon
You can compare error._code
and if it is equal to -1001
which is NSURLErrorTimedOut then you know this was a timeout.
let manager = Alamofire.SessionManager.default
manager.session.configuration.timeoutIntervalForRequest = 120
manager.request("yourUrl", method: .post, parameters: ["parameterKey": "value"])
.responseJSON {
response in
switch (response.result) {
case .success: // succes path
case .failure(let error):
if error._code == NSURLErrorTimedOut {
print("Request timeout!")
}
}
}