Use
connectionError.localizedDescription
There is useful article about NSError
In case if there is no error connectionError object will be nil.
Question
I am setting up a NSURLConnection which send an asynchrounous request and deals with it using a completionHandler.
__block int errorType = 0; //server error code: 200, 300 etc..
__block BOOL hasError = FALSE;
__block NSDictionary *json;
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// HERE I WOULD LIKE TO INTERPRET connectionError
// AND SET IF IT HASERROR OR NOT as well as the error type
json = [NSJSONSerialization JSONObjectWithData:data
options:0
error:nil];
}];
Based on the error type I would need to do different things. The only issue is that I do not know how to interpret the error in this context.
I need to extract information like: "the request was not sent", "the request was sent".
Any suggestion / reference?
Solution
Use
connectionError.localizedDescription
There is useful article about NSError
In case if there is no error connectionError object will be nil.