How to display text label in tableView cell

3k views Asked by At

I have populated a tableview with an array of arrays, but I do not know how to display text as the cell label.

I want to use the string in the "0" position of the array that is inside the array as the text label.

Thanks.

Here's my code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    // Set up the cell...
    cell.textLabel.text = [excersizeArray objectAtIndex:indexPath.row];    
    return cell;
}
1

There are 1 answers

0
Evan Mulawski On BEST ANSWER

You need to access the array within the array since you have an array of arrays:

cell.textLabel.text = [[excersizeArray objectAtIndex:indexPath.row]objectAtIndex:0];

This get's the array at index indexPath.row (the table's row) from exercisesArray.

[excersizeArray objectAtIndex:indexPath.row]

This get's the string (as you implied) from that array (the inner array).