I am creating a table with 20 cells.
And when I select the first line, a checkmark will be displayed on it.

But when I look at the table view, then this is not only one checkmark on the tableview cell.
It also appears in another cell.

What is the problem with this?
self.dataAry = [NSArray arrayWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",nil]; marks = [NSMutableArray new]; for (int i = 0 ; i < [self.dataAry count]; i++) { [marks addObject:@"NO"]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = [dataAry objectAtIndex:indexPath.row]; if ([[marks objectAtIndex:indexPath.row] isEqualToString:@"YES"]) { [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; }else { [cell setAccessoryType:UITableViewCellAccessoryNone]; }
source share