There is a funny mistake here.
if (row != oldRow)
because if oldRow was nil (or in other words ... "0" ;-), and the user presses the string = "0", the sentence "if" will consider this string checked.
I recorded the following:
- (void) tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath { if (!self.lastIndexPath) { self.lastIndexPath = indexPath; } if ([self.lastIndexPath row] != [indexPath row]) { UITableViewCell *newCell = [tableView cellForRowAtIndexPath: indexPath]; newCell.accessoryType = UITableViewCellAccessoryCheckmark; UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:self.lastIndexPath]; oldCell.accessoryType = UITableViewCellAccessoryNone; self.lastIndexPath = indexPath; } else { UITableViewCell *newCell = [tableView cellForRowAtIndexPath: indexPath]; newCell.accessoryType = UITableViewCellAccessoryCheckmark; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; }
By the way ... don't forget to use the "I"
source share