在tableView中显示数组中的数据

时间:2011-03-23 17:23:04

标签: iphone objective-c cocoa-touch ios

我有一个如下所示的数组。

记录 - >记录列表 - >每条记录下面有9条不同的记录是控制台的输出。

当我将数组打印到控制台

时会发生这种情况
2011-03-23 17:21:25.003 twosmsapp[5189:207] (
    447879652048,
    SUCCESS,
    "2011-03-23T15:56:54.222Z",
    "2011-03-23T15:56:54.223",
    "",
    "2011-03-23T15:56:55.977",
    "2011-03-23T15:57:04.177",
    Lalalalala,
    "2011-03-23 15:56:54.450ZVCLMKDRWBETW84AL"
)
2011-03-23 17:21:25.004 twosmsapp[5189:207] (
    447790686158,
    SUCCESS,
    "2011-03-23T12:24:12.844Z",
    "2011-03-23T12:24:12.843",
    "",
    "2011-03-23T12:24:13.540",
    "2011-03-23T12:24:23.453",
    "Another test",
    "2011-03-23 12:24:12.937CFOCJHXSZIETW85TS"
)
2011-03-23 17:21:25.004 twosmsapp[5189:207] (
    447790686158,
    SUCCESS,
    "2011-03-23T09:22:36.339Z",
    "2011-03-23T09:22:36.340",
    "",
    "2011-03-23T09:22:37.257",
    "2011-03-23T09:22:48.290",
    Hellloooo,
    "2011-03-23 09:22:36.660BJJJFMCSZIETW85OO"
)

我想在tableView中显示这些数据。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

正如您在其他问题中所述,以下是您制作阵列的方式:

[records addObject:[NSArray arrayWithObjects:
                                  [TBXML textForElement:destination],
                                  [TBXML textForElement:status],
                                  [TBXML textForElement:guid],
                                  [TBXML textForElement:dateSub],
                                  [TBXML textForElement:dateToSend],
                                  [TBXML textForElement:dateSent],
                                  [TBXML textForElement:dateReceived],
                                  [TBXML textForElement:message],
                                  [TBXML textForElement:id],nil]]; 

因此,以下是如何在单元格的一行显示目标,状态,dateSent和消息:(可能需要缩小文本大小)

cell.textLabel.text = [NSString stringWithFormat:@"%@, %@, %@, %@",
                          [[records objectAtIndex:indexPath.row] objectAtIndex:0],
                          [[records objectAtIndex:indexPath.row] objectAtIndex:1],
                          [[records objectAtIndex:indexPath.row] objectAtIndex:5],
                          [[records objectAtIndex:indexPath.row] objectAtIndex:7]];