【发布时间】:2012-08-02 20:23:16
【问题描述】:
我有一个来自 Flickr api 请求的 NSDictionary 响应,它的描述如下所示:
self.userInfo: {
"_text" = "\n\n";
person = {
"_text" = "\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n";
description = {
};
iconfarm = 0;
iconserver = 0;
id = "83943196@N02";
ispro = 0;
location = {
};
"mbox_sha1sum" = {
"_text" = 7b61c5d24f12345678be82c31234567830540;
};
mobileurl = {
"_text" = "http://m.flickr.com/photostream.gne?id=12345678";
};
nsid = "12345678@N02";
"path_alias" = "";
photos = {
"_text" = "\n\t\t\n\t\t\n\t\t\n\t\t\n\t";
count = {
"_text" = 2;
};
firstdate = {
"_text" = 12345678;
};
firstdatetaken = {
"_text" = "2012-08-01 12:46:38";
};
views = {
"_text" = 0;
};
};
photosurl = {
"_text" = "http://www.flickr.com/photos/12345678@N02/";
};
profileurl = {
"_text" = "http://www.flickr.com/people/12345678@N02/";
};
realname = {
"_text" = "Me TheUser";
};
timezone = {
label = "Pacific Time (US & Canada); Tijuana";
offset = "-08:00";
};
username = {
"_text" = metheuser;
};
};
stat = ok;
}
我很难弄清楚如何将实名值提取到 NSString 中。
我试过了:
NSString * temp = [self.userInfo valueForKey:@"realname"];
NSLog (@"FL: nameOfSignedInUser. nameself.userInfo: %@", temp.debugDescription);
但返回为零。
谢谢!
【问题讨论】:
-
看起来
realname对象嵌套在person对象中,您是否尝试过将person作为字典检索,然后从中获取realname? -
是的,谢谢你的提示。我检查了计数和它的 3。我猜第一个是测试,第二个是人,第三个是统计
-
如有疑问,请遍历所有根对象的键和对象以查看您拥有的内容。在处理从 XML 解析的任意 Web 服务返回值时,我使用了类似的过程
标签: objective-c ios nsdictionary