I solved it! The problem was that because of other reasons, I wasn't able to reuse my cells and this was my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *kCustomCellID = [NSString stringWithFormat:@"MyCellID%d", indexPath];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCustomCellID];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCustomCellID] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
if (selectOrDeselectInteger == 1) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
if (selectOrDeselectInteger == 2) {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
I just had to add this afterwards:
if (cell != nil)
{
if (selectOrDeselectInteger == 1) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
if (selectOrDeselectInteger == 2) {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
Thanks everyone for the help. Sorry this code wasn't in the question.