Yes, you should put it in the cellForRowAtIndexPath: delegate method, outside of the "if (cell == nil)" statement. Since the cells are recycled, you have to make sure that the accessory type is set to the right value for every cells and not only the one(s) that need specific accessory type.
For example :
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)ip {
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"CELL"];
if (cell == nil) {
cell = [[[UITableView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CELL"] autorelease];
}
if (ip.row == 3) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
This code would not work the way we want it to. Since the cells are recycled, the cell with accessory type set to UITableViewCellAccessoryDisclosureIndicator will be reused later at an undefined row and would then exhibit a disclosure indicator even if it is not located at row #3.
To deal with cells reusing, we have to set accessory type for EVERY cells, whatever their row :
if (ip.row == 3) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else {
cell.accessoryType = UiTableViewCellAccessoryNone;
}
I don't know for sure if this explains your problem, but it sure looks related to cell reusing.
EDIT :
OK, you found the solution by yourself while I was typing my answer. :o)