I use NSURLConnection's sendSynchronousRequest:returningResponse:error: method (in a separate NSOperation thread) to connect to external server to retreive data. How do I know if the operation ended timed out, or some other network error?
If there was an error, the error parameter will be non-nil when sendSynchronousRequest:returningResponse:error: returns.
You can retrieve the error code by checking the value returned by [NSError code]. The error code for time out is NSURLErrorTimedOut.
For instance:
NSError *error = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]
if (error.code == NSURLErrorTimedOut) {
// Handle time out here
}
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