将字典转换成一个数组 [英] Convert Dictionaries into one array
本文介绍了将字典转换成一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码:
for (NSDictionary *object in JSONArray) {
NSMutableArray *birdtemp = [[NSMutableArray alloc] initWithObjects:object[@"case_name"], nil];
[allparts addObject:birdtemp];
}
输出此日志:
log: (
(
"NZXT Phantom 410"
),
(
"Thermaltake MK+"
)
)
我想知道我可以使用什么代码制作该日志分成一个数组,例如:
I want to know what code I could use to make that log into one array like:
log: (
"NZXT Phantom 410",
"Thermaltake MK+"
)
Json Array是:
Json Array is:
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;
}
)
推荐答案
已解决问题并得到以下信息:
Troubleshooted and got this:
allparts = [[NSMutableArray alloc] init];
NSString *birdtemp;
for (NSDictionary *object in JSONArray) {
birdtemp = object[@"case_name"];
[allparts addObject:birdtemp];
}
这篇关于将字典转换成一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文