我一直在想几天来弄清楚如何解析这个JSON到一个分段的UITable,但我不成功,我只能弄清楚如何获得节名称,但未能获取每个部分中每一行的行数和数据。分段的UITable&JSON
由于交通团队可能会不时变化,他们的名字可能会改变,所以我想我需要使用allKeys来找出每节的标题1st。
请帮助并指出我正确的方向来提取分区UITable的数据,谢谢。
{
"transport" : {
"public" : [
{
"transport_id" : "2",
"transport_name" : "Ferry"
},
{
"transport_id" : "3",
"transport_name" : "Bus"
},
{
"transport_id" : "4",
"transport_name" : "Taxi"
},
{
"transport_id" : "5",
"transport_name" : "Tram"
}
],
"Private" : [
{
"transport_id" : "11",
"transport_name" : "Bicycle"
},
{
"transport_id" : "12",
"transport_name" : "Private Car"
}
],
"Misc" : [
{
"transport_id" : "6",
"transport_name" : "By Foot"
},
{
"transport_id" : "7",
"transport_name" : "Helicopter"
},
{
"transport_id" : "8",
"transport_name" : "Yatch"
}
]
}
}
NSDictionary *results = [jsonString JSONValue];
NSDictionary *all = [results objectForKey:@"transport"];
NSArray *allKeys = [all allKeys];
NSArray *transports = [results objectForKey:@"transport"];
for (NSDictionary *transport in transports)
{
[transportSectionTitle addObject:(transport)];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [transportSectionTitle count];
}
你想说,运输,公私错过这些改变或在其内部的数据在一段时间内发生变化。 – 2012-01-27 08:33:39