0

我正在尝试将一些 XML 数据解析为一个数组,然后在第一个视图控制器的表视图中显示该数组。可以看到我已经把数据解析成我需要的了,然后就全部设置在数组中了。我只是不知道如何让它发送到 GUI 中的表视图。这是我的数组:

    NSString* mountPoint1 = [mountArray objectAtIndex: 11];
    NSString* mountPoint2 = [mountArray objectAtIndex: 17];
    NSString* mountPoint3 = [mountArray objectAtIndex: 23];
    NSString* mountPoint4 = [mountArray objectAtIndex: 29];
    NSString* currentSong1 = [mountArray objectAtIndex: 16];
    NSString* currentSong2 = [mountArray objectAtIndex: 22];
    NSString* currentSong3 = [mountArray objectAtIndex: 28];
    NSString* currentSong4 = [mountArray objectAtIndex: 34];
    NSString* listeners1 = [mountArray objectAtIndex: 14];
    NSString* listeners2 = [mountArray objectAtIndex: 20];
    NSString* listeners3 = [mountArray objectAtIndex: 26];
    NSString* listeners4 = [mountArray objectAtIndex: 32];
    NSLog(@"mountpoint1 should be dev = %@", mountPoint1);
    NSLog(@"All data = %@", mountArray);
    // First mount is 11
    NSLog(@"First mount point = %@", mountPoint1);
    NSLog(@"Currrent Song playing on mount Dev = %@", currentSong1);
    NSLog(@"Currrent listeners on mount Dev = %@", listeners1);
    NSLog(@"Second mount point = %@", mountPoint2);
    NSLog(@"Currrent Song playing on mount Metal = %@", currentSong2);
    NSLog(@"Currrent listeners on mount Metal = %@", listeners2);
    NSLog(@"Third mount point = %@", mountPoint3);
    NSLog(@"Currrent Song playing on mount OrienLive = %@", currentSong3);
    NSLog(@"Currrent listeners on mount OrienLive = %@", listeners3);
    NSLog(@"Fourth mount point = %@", mountPoint4);
    NSLog(@"Currrent Song playing on mount Rock = %@", currentSong4);
    NSLog(@"Currrent listeners on mount Rock = %@", listeners4);
4

1 回答 1

1

你到底想做什么?您可以执行以下操作:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //.. after initial setup
    NSInteger position = indexPath.row * 6;
    cell.mountLabel.text = [self.mountArray objectAtIndex:position + 11];
    cell.songLabel.text = [self.mountArray objectAtIndex:position + 16];
    cell.listenerLabel.text = [self.mountArray objectAtIndex:position + 14];
    //.. continue with other setup
}

类似的东西?

于 2012-09-18T19:03:32.173 回答