这段代码:
for (NSDictionary *object in JSONArray) {
NSMutableArray *birdtemp = [[NSMutableArray alloc] initWithObjects:object[@"case_name"], nil];
[allparts addObject:birdtemp];
}
输出此日志:
log: (
(
"NZXT Phantom 410"
),
(
"Thermaltake MK+"
)
)
我想知道我可以使用什么代码将日志记录到一个数组中,例如:
log: (
"NZXT Phantom 410",
"Thermaltake MK+"
)
Json Array是:
log: (
{
"case_color" = White;
"case_description" = "";
"case_image" = "http://sitecom/get/parts/part_images/nzxtphantom410.jpeg";
"case_name" = "NZXT Phantom 410";
"case_price" = "99.99";
"case_type" = ATX;
id = 1;
},
{
"case_color" = Black;
"case_description" = "";
"case_image" = "http://site.com/get/parts/part_images/thernaltake-mkplus.jpeg";
"case_name" = "Thermaltake MK+";
"case_price" = "84.99";
"case_type" = ATX;
id = 2;
}
)
最佳答案
NSMutableArray *array = [[NSMutableArray alloc] init];
for (NSDictionary *dict in JSONArray) {
[array addObject:[dict objectForKey:@"case_name"]];
}
NSLog(@"Your Array: %@",array);
我认为这将对您有所帮助。