<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem 。这将有助于其他人回答问题。
关闭 8 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem 。这将有助于其他人回答问题。
关闭 8 年前。
我得到了 NSDictionary
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";
};
}
它只得到一个关键的“结果” 我如何获得其他 key ?
最佳答案
gameDict 是具有一个键/对的 NSDictionary。键“结果”指向另一个 NSDictionary,它有更多的键。因此,要访问任何更深层次的键,您可以内联进行:
NSNumber *score = gameDict[@"result"][@"score"];
或者你也可以把字典拿出来查询
NSDictionary *resultDict = gameDict[@"result"];
NSNumber *score = resultDict[@"score"];
关于ios - NSDictionary 从一键到多键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29212198/