我在NSDictionary中有以下值。
{"data":[
{"name":"Cem Aykutalp","id":"1538278008"},
{"name":"Pasqual Martin","id":"1841753129"},
{"name":"Yusuf Do\u011fan","id":"100000024057687"},
{"name":"New Wave","id":"100000409270728"},
{"name":"DanRey Dumalag","id":"100000446097675"},
{"name":"Rushikesh Dhruva","id":"100000603556855"},
{"name":"Ricsi Zov\u00e1nyi","id":"100001018351273"},
{"name":"Pero Peri\u0107","id":"100002192083309"},
{"name":"Ayse Suer","id":"100002502298417"},
{"name":"Miranda Johnson","id":"100002554868458"}
]}
如何从该词典中检索名称和ID标记。
答案 0 :(得分:3)
NSString *name = [[[yourDict objectForKey:@"data"] objectAtIndex:0] objectForKey:@"name"];
NSString *yourId = [[[yourDict objectForKey:@"data"] objectAtIndex:0] objectForKey:@"id"];
这仅适用于第一个数组,如果你想从yourDict获取所有名称和id,而不是使用for循环。