使用该代码,我能够获得所有数组列表。
看了很多教程,但我无法得到名为" id"如果"名称"等于"时间轴照片"。
代码:
NSArray *feed =[result objectForKey:@"data"];
for (NSDictionary *dict in feed) {
NSLog(@"%@",dict);
}
结果(前两个结果的示例):
2015-02-03 13:59:21.246 Project[708:29363] {
"can_upload" = 0;
count = 68;
"cover_photo" = 10200808394440000;
"created_time" = "2011-03-09T17:25:03+0000";
from = {
id = 10204248513160000;
name = "XX XX";
};
id = 1716972770000;
link = "https://www.facebook.com/album.php?..";
name = "Mobile Uploads";
privacy = everyone;
type = mobile;
"updated_time" = "2015-01-31T13:28:32+0000";
}
2015-02-03 13:59:21.247 Project[708:29363] {
"can_upload" = 0;
count = 11;
"cover_photo" = 4383404270000;
"created_time" = "2010-02-15T15:50:30+0000";
from = {
id = 10204248513160000;
name = "XX XX";
};
id = 1267183610000;
link = "https://www.facebook.com/album.php?...";
name = "Timeline Photos";
privacy = everyone;
type = wall;
"updated_time" = "2015-01-28T18:26:52+0000";
}
答案 0 :(得分:1)
试试这个:
NSArray *feed =[result objectForKey:@"data"];
for (NSDictionary *dict in feed) {
if ([dict[@"name"] isEqualToString:@"Timeline Photos"])
NSLog(@"%@",dict[@"id"]);
}
当id
等于时间轴照片时,这只会打印name
。
实际上,你不是在使用数组,而是使用字典。
希望这有帮助。