Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 从NSDictionary中提取信息_Objective C_Ios_Nsdictionary - Fatal编程技术网

Objective c 从NSDictionary中提取信息

Objective c 从NSDictionary中提取信息,objective-c,ios,nsdictionary,Objective C,Ios,Nsdictionary,我收到来自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";

我收到来自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;
}
我正在让truoble研究如何将realname值提取到NSString中

我试过:

NSString * temp = [self.userInfo valueForKey:@"realname"];
NSLog (@"FL: nameOfSignedInUser. nameself.userInfo: %@", temp.debugDescription);
但结果是零


谢谢大家!

看起来
realname
对象嵌套在
person
对象中,您是否尝试将
person
作为字典检索,然后从中获取
realname
?是的,谢谢您的提示。我查了一下计数和它的3。我猜第一个是test,第二个是person,第三个是statw当有疑问时,迭代所有根对象的键和对象,看看你有什么。在处理从XMLDamit解析的任意webservice返回值时,我使用了类似的过程;我敢肯定,当我回答我的问题时,你的答案看起来不是那样的(完全一样!)。我将删除我的…@特洛伊木马对不起,我删除并更改了它。我没有看到其他人的帖子。在这里,EJV确实是正确的答案。我从未使用过
valueForKeyPath:
很高兴知道。是的,我甚至在NSArray类参考文档中都没有看到它。仅在NSKeyValueCoding协议参考中
NSString *realName = [[[self.userInfo objectForKey:@"person"] objectForKey:@"realname"] objectForKey:@"_text"];
NSString *name = [self.userInfo valueForKeyPath:@"person.realname._text"];