1
我有JSON格式看起來像這樣一些數據來創建一個NSArray:從JSON數據
{"YrMonth":201109,"StrYrMonth":"Sep-2011","Value":"49275.14"}
{"YrMonth":201110,"StrYrMonth":"Oct-2011","Value":"52087.22"}
etc...
使用NSJSONSerialization
我存儲在一個名爲「指示器」數組中此數據。 當我想用這個數據只顯示在的tableView的關鍵「價值」的項目,我可以做到這一點罰款:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];
cell.textLabel.text = [[indicator objectAtIndex:indexPath.row] objectForKey:@"Value"];
return cell;
}
我的問題是:我怎麼可以創建一個數組,我可以在cellForRowAtIndexPath
之外使用每個鍵的值? 例如:
An array for key "StrYrMonth" which contains only: "Sep-2011", "Oct-2011", etc...
An array for key "Value" which contains only: "49275.14", "52087.22", etc...
我最終會做的是使用「值」數組繪製在CorePlot線和「StrYrMonth」數組定義圖表的德x軸標籤。
在此先感謝您的幫助!
+1快速和良好的答案。 – Dilip 2013-02-19 13:46:41
謝謝!我知道答案很簡單! – 2013-02-19 13:51:42