i use AFNetworking to retrieve data from my web service every thing work perfectly, but i want to detect the time out error. I used this code in the failure block of the request but i don't work
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if ([operation.response statusCode] == 408) {
//time out error here
}
}];
The code 408 is normaly for the time out error
Since AFNetworking is build on top on NSULConnection/NSULRSession you can just NSURLErrorTimedOut
to check if the error is a timeout error:
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (error.code == NSURLErrorTimedOut) {
//time out error here
}
}];
You where checking the HTTP status code, but since the connection timed out there is not statuscode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With