【问题标题】:JSON array into a tableView cellJSON 数组放入 tableView 单元格
【发布时间】:2011-03-13 15:12:19
【问题描述】:

在一个 HTTP 请求之后,我收到一个 JSON 数组,用以下代码解码:

NSArray *jsonArray = [stringResponse JSONValue];

数组看起来像:

(
{
    id = 0000000002;
    ora = "15:00:00";
    oraArrivo = "21:20:00";
},
    {
    id = 0000000001;
    ora = "19:20:00";
    oraArrivo = "23:30:00";
}
)

现在我必须将每个数组项插入一个 uitableview 行。我试过了:

cell.textLabel.text = [self.jsonArray objectAtIndex:indexPath.row];

但它不起作用。我可能还需要一些东西。

我编辑的“原始”UiTableView 代码的另一部分是:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return jsonArray.count;
}

我只需要在 tableView 中有行就像

“出发时间为15:00:00 到达时间为21:20:00”

关于如何使它工作的任何建议?

谢谢。

【问题讨论】:

    标签: json ios4 uitableview nsarray


    【解决方案1】:

    解决了

        NSDictionary *dict = [self.jsonArray objectAtIndex: indexPath.row];
        cell.textLabel.text = [dict objectForKey:@"ora"];
        cell.detailTextLabel.text = [dict objectForKey:@"oraArrvo"];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-12
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      • 2021-10-16
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多