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 に答える