简体   繁体   English

从NSDictionary提取信息

[英]extracting information from NSDictionary

I have a NSDictionary response from a Flickr api request and it's description looks like this: 我从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;
}

I'm having truoble figuring out how to extract the realname value into a NSString. 我有麻烦找出如何将实名值提取到NSString中。

I've tried: 我试过了:

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

but that comes back as nil. 但这回来为零。

thank you! 谢谢!

NSString *name = [self.userInfo valueForKeyPath:@"person.realname._text"];
NSString *realName = [[[self.userInfo objectForKey:@"person"] objectForKey:@"realname"] objectForKey:@"_text"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM