首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSDictionary从一个密钥到多个

NSDictionary从一个密钥到多个
EN

Stack Overflow用户
提问于 2015-03-23 14:00:02
回答 1查看 37关注 0票数 0

我得到了NSDictionary

代码语言:javascript
复制
Printing description of gameDict:
{
    result =     {
        developer = "Bethesda Game Studios";
        genre = "Role-Playing";
        name = "The Elder Scrolls V: Skyrim";
        platform = "PlayStation 3";
        publisher = "Bethesda Softworks";
        rating = M;
        rlsdate = "2011-11-11";
        score = 92;
        summary = "The next chapter in the Elder Scrolls saga arrives from the Bethesda Game Studios. Skyrim reimagines the open-world fantasy epic, bringing to life a complete virtual world open for you to explore any way you choose. Play any type of character you can imagine, and do whatever you want; the legendary freedom of choice, storytelling, and adventure of The Elder Scrolls is realized like never before. Skyrim's new game engine brings to life a complete virtual world with rolling clouds, rugged mountains, bustling cities, lush fields, and ancient dungeons. Choose from hundreds of weapons, spells, and abilities. The new character system allows you to play any way you want and define yourself through your actions. Battle ancient dragons like you've never seen. As Dragonborn, learn their secrets and harness their power for yourself.";
        thumbnail = "http://static.metacritic.com/images/products/games/6/372529409ea6cc3faadf5674fd96ba2a-98.jpg";
        url = "http://www.metacritic.com/game/playstation-3/the-elder-scrolls-v-skyrim";
        userscore = "6.3";
    };
}

它只有一个键“结果”,我怎么能得到其他的钥匙?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-23 14:05:40

gameDict是一个只有一个键/对的NSDictionary。键“结果”指向另一个NSDictionary,它有更多的键。因此,要访问任何更深的键,您可以内联地这样做:

代码语言:javascript
复制
NSNumber *score = gameDict[@"result"][@"score"];

或者你可以拿出字典来查询它

代码语言:javascript
复制
NSDictionary *resultDict = gameDict[@"result"];
NSNumber *score = resultDict[@"score"];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29212198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档