iPhone NSURLConnection:如何处理返回的 NSData 对象?谷歌文档 API

发布于 2024-08-15 17:46:21 字数 505 浏览 4 评论 0原文

我正在我的 iPhone 应用程序中使用 Google Docs API。我已经发送了正确的 POST 请求,并收到了响应以及一些 NSData。如果我对 NSData 对象进行 NSLog,我会得到:

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

我认为 NSData 要么是 NSDictionary,要么是 NSArray。我应该收到几个返回的项目:一个 SID、一个 LSID 和一个 Auth。

如果我可以将 NSData 块转换为 NSDictionary,我就可以找到任意键的对象。

有人可以帮忙吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

在你怀里撒娇 2024-08-22 17:46:21

您必须对数据进行解码。尝试以下操作:

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

当然,这取决于数据的编码方式。 NSUTF8StringEncoding 可能会起作用。

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.

女皇必胜 2024-08-22 17:46:21

您可能只需要将数据传递给 NSXMLParser

You may just need to pass the data to an NSXMLParser

缺⑴份安定 2024-08-22 17:46:21

处理 Web 数据的最佳方法是进行 NSXML 解析。无需解码数据,解析器将自行处理

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文