in iOS, how can I receive the http status code (404,500 200 etc) for a response from a web server. I am assuming it's in the NSUrlConnectionDelegate.
Objective-C or Monotouch .NET answer ok.
in iOS, how can I receive the http status code (404,500 200 etc) for a response from a web server. I am assuming it's in the NSUrlConnectionDelegate.
Objective-C or Monotouch .NET answer ok.
Here's how to do it in MonoTouch for .NET for those C# users. THis is in the NSUrlConnectionDelegate.
The aSynchronous request should also have a way to get the NSHTTPURLResponse..
You get the status code like this:
In the case of some much used error codes (like 404) it will get put in the error but with a different code (401 will be -1012).
Looking at this other stackoverflow question it looks like you can handle http status codes in the
- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)response
delegate method:Yes, you can get status code in delegate method -didRecieveResponse: