Problem implementing a UITableView that allows for multiple row selections

Posted by wgpubs on Stack Overflow See other posts from Stack Overflow or by wgpubs
Published on 2010-04-15T07:40:36Z Indexed on 2010/04/15 7:43 UTC
Read the original article Hit count: 197

This

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

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
int cardNumber = indexPath.row + 1;

if (cell.accessoryType == UITableViewCellAccessoryNone) {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    if (![self.winningNumbers containsObject:[NSNumber numberWithInt:cardNumber]])
        [self.winningNumbers addObject:[NSNumber numberWithInt:cardNumber]];
}
else {
    cell.accessoryType = UITableViewCellAccessoryNone;
    if ([self.winningNumbers containsObject:[NSNumber numberWithInt:cardNumber]])
        [self.winningNumbers removeObject:[NSNumber numberWithInt:cardNumber]];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];

}

... modifies the "accessoryType" of every 6th cell INSTEAD of just the selected row. What am I missing?

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview