Moshe
Moshe

Reputation: 58087

Getting info from NSData object

How would I get returningResponse (into say, a NSString) from the following code:

NSURLResponse* response;
NSError* error;
NSData* result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];

I think I can get the info that I need into a string but I can't call anything on response because it's null. Therefore, I assume that I need to call something on result. The problem is, I don't know what to call.

(The URL request has been coded prior to the code sample. I know that that works.) I want to be able to detect if the request as successful.

Upvotes: 0

Views: 441

Answers (1)

David Gelhar
David Gelhar

Reputation: 27900

According to the documentation for the URL loading system:

If NSURLConnection is unable to download the URL the method will return nil and any available NSError instance by-reference in the appropriate parameter.

So, see what's in your "error" parameter to find out what the problem is.

Upvotes: 1

Related Questions