I'm using json-framework on iPhone to connect to a web service built in asp.net. Sometimes asp.net throws errors on the web service. But I can't find a way to handle them on the iPhone as they doesn't seem to be recognised as errors by NSURLConnection. When looking at the response data it shows the error in json format, how can I in an easy way handle this error?
NSError* requestError = nil;
NSData* responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&requestError];
//requestError is still nil even if I get asp.net errors on the server.
SBJSON *parser = [[SBJSON alloc] init];
NSString *jsonResponseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSError *jsonParserError = nil;
NSDictionary *jsonResponse = [parser objectWithString:jsonResponseString error:&jsonParserError];
//jsonParserError is still nil because the response data is in json format, so it wont recognise the error.
Hope you understand what I'm talkning about, just want an easy way to check if error then handle it, maybe show an alert for the user or something. Thanks!