views:

224

answers:

3

I'm working with the Google Docs API in my iPhone application. I've sent the proper POST request, and received a response along with some NSData. If I NSLog the NSData object, I get this:

NSData *returnedData = [NSURLConnection sendSynchronousRequest:request returningResponse:theResponse error:NULL];
NSLog(@"%@",returnedData);
//output : <4572726f 723d4261 64417574 68656e74 69636174 696f6e0a>

I think the NSData is either an NSDictionary or an NSArray. I'm supposed to receive a couple of items back, an SID, an LSID, and an Auth.

If I could turn the NSData chunk into an NSDictionary I could just find the object for whichever key.

Can anyone help?

+5  A: 

You will have to decode the data. Try the following:

NSString *result= [[NSString alloc] initWithData:returnedData encoding:NSASCIIStringEncoding];

Of course this will depend on how the data is encoded. NSUTF8StringEncoding might work instead.

chris
The selected answer is what worked. Now I'm going to ask another question! http://stackoverflow.com/questions/1955990/iphone-google-data-api-http-protocol-auth-token-from-stringFREE POINTS TO THE FIRST GREAT ANSWER!
JustinXXVII
A: 

You may just need to pass the data to an NSXMLParser

jessecurry
A: 

The best way to deal with web data is Doing NSXML parsing. No need of decoding data the parser will handle itself

Madhup