Reputation: 10600
its one mandatory.the problem is the checkmark sign by default move down to 11 paces. so if you have 9 item in a list, you see that not happening with 9 item in a list. but if you have 30 item in a list, you will see 3 checkmark.but it should be one which one i have choice?.isSelect == true
if choice?.isSelect == true {
//this code execute one time
print("===========Checkmark=================")
cell.accessoryType = .checkmark
}
One point out : tableview its reuse privious cell so if cell has already checked then 11th cell automatic checked. how can i fix?
Upvotes: 0
Views: 50
Reputation: 1340
Just put else condition
if choice?.isSelect == true {
//this code execute one time
print("===========Checkmark=================")
cell.accessoryType = .checkmark
}else{
cell.accessoryType = .none
}
Upvotes: 1
Reputation: 11233
Perhaps due to re-usability previously added check mark remains on the cell. Try like this:
if choice?.isSelect == true {
//this code execute one time
print("===========Checkmark=================")
cell.accessoryType = .checkmark
}
else
{
cell.accessoryType = .none
}
Upvotes: 1