views:

210

answers:

1

I am trying to pull some data from a server (I don't own the server) however it returns some needed data with a http 500 error code, however NSString stringWithContentsOfURL returns nil if the server returns http code 500.

I'd like to retrieve the data even if the server returns 500.

+3  A: 

NSURLConnection (as part of the URL Loading System) will give you the lower-level control over the request and the interpretation of the response; you will have to implement a few call-back methods to handle fine grained control of the request (and you can opt to invoke it synchronously to mimic stringWithContentsOfURL:, but it will give you what you want.

[NSString stringWithContentsOfURL:] is a great convenience, but in your case you want to circumvent the way cocoa interprets HTTP response codes, so that requires a smidge more work.

Jarret Hardie