我有一个json数据
"Arfb Kash" = {
g = 9q9hrh1bbv;
location = (
"37.3317034",
"-122.0336955"
);
title = "Arfb Kash";
};
"Aryan Kashyap" = {
g = 9q9hrh5sdd;
location = (
"37.33233141",
"-122.0312186"
);
title = "Aryan Kashyap";
};
Park = {
g = 9q9hrh44su;
location = (
"37.3319949",
"-122.0331756"
);
};
}
我想枚举这些数据并获取我使用iOS Objective c的每个参数的标题字符串,并帮助如何做到这一点?
答案 0 :(得分:1)
您可以使用快速枚举执行此操作。
NSDictionary *dictionary = /* your dictionary from the question */;
NSMutableArray *titles = [[NSMutableArray alloc] init];
for (NSString *key in dictionary) {
NSDictionary *subDictionary = dictionary[key];
NSString *title = subDictionary[@"title"];
if (title) {
[titles addObject:title];
}
}