iOS Table View Deselecting row automatically

Hello I'm trying to do Apple tutorial's on making a To Do List, but there is a problem while trying to check a To Do Item on the List.

Im doing the following code:

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath     *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated: NO];

    ToDoItem *tappedItem = [self.toDoItems objectAtIndex:indexPath.row];
    tappedItem.completed = !tappedItem.completed;

    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}

But in the simulator, when I click on one item it stays selected but only gets checked when I click on other. What am I doing wrong?

Thank you in advance.

Upvotes: 0

Views: 346

Answers (1)

rdelmar
rdelmar

Reputation: 104082

It's because you've implemented didDeselectRowAtIndexPath, rather than didSelectRowAtIndexPath.

Upvotes: 2

Related Questions