LIAL
LIAL

Reputation: 1634

didSelectRowAtIndexPath: how to get old indexPath to deselect checkmark?

How to deselect previously selected row in tableView ?? I can't find solution to obtain oldIndexPath

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
    if (newCell.accessoryType == UITableViewCellAccessoryNone) {
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;
    }  
}

Upvotes: 1

Views: 1493

Answers (1)

user756245
user756245

Reputation:

Unless you store the previous index path, you won't be able to retrieve it.
Just store it in an ivar, when you detect a row is selected, the next time you will be able to remove the checkmark on the previous cell.

Upvotes: 2

Related Questions