I am working on an app that queries a web service. I want to know how can I handle errors like "404" (NOT FOUND). The delegate method
connection:(NSURLConnection *)conn didFailWithError:(NSError *)error only handles errors caused by connection. I have been told that dealing with those errors should be in
connection:(NSURLConnection *)conn didReceiveData:(NSData *)data method, how can I do that? I've been looking over the documentation, there is no such property of NSURLRequest like "ResponseCode" or something. Any help is appreciated.
Implement the following delegate method
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
Then check the response object for a statusCode property. You may have to cast it to NSHTTPURLResponse to see it.