I am having a problem with my code skipping over the if(cell == nil) after about nine trips through the cellForRowAtIndexPath. Then items in my table start repeating and do so every nine items. When I remove the if(cell == nil) line, the table comes out beautifully, with all the data in the right order. However, if I scroll to the bottom of the table, my app crashes so that is not a good solution. Any ideas please??
Thank you!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
NSString *temp = [[views objectAtIndex:indexPath.row] objectForKey:@"racer"];
NSString *val = [[views objectAtIndex:indexPath.row] objectForKey:@"pointsScored"];
// Set up the cell...
cell.textLabel.text = temp;
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.detailTextLabel.text = val;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
[temp release];
[val release];
}
return cell;
}