I am getting duplicates of my array, and wrongly displayed cells in this method:
Here I am initializing the array, and adding it to the tableView:
NSArray *sectionsArray = [NSArray arrayWithObjects: @"Location", @"Front Post", @"Front Fixing", @"Front Footplate", @"Rear Post", @"Read Fixing", @"Rear Footplate", @"Horizontal Bracing", @"Diagonal Bracing", @"Front Beam", @"Front Lock", @"Rear Beam", @"Rear Lock", @"Guard", @"Accessories", @"Comments", @"Off load ref", @"Loc Empty", @"Loc Affected", nil];
[_tableArray setObject:sectionsArray atIndexedSubscript:2];
[_tableView reloadData];
For some weird reason there are always the 4th object that is messed up, and is either duplicated, or do not have the views from IB. Here is the cellForRowAtIndexPath: method:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (indexPath.section == 2) {
cell = [tableView dequeueReusableCellWithIdentifier:@"EntryCell"];
cell.tag = indexPath.row;
UILabel *label = (UILabel *)[cell viewWithTag:3];
[label setText:[[_tableArray objectAtIndex:2] objectAtIndex:indexPath.row]];
}
return cell;
}
I have logged the string [[_tableArray objectAtIndex:2] objectAtIndex:indexPath.row], and it logs the right string.