R – iPhone NSURLConnection: What to do with returned NSData Object? Google Docs API

iphonensdatansurlconnectionobjective c

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?

Best Answer

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.

Related Topic