Using the following code, when I click a cell to create a checkmark accessory, it repeats the checkmark every 12 rows. Any ideas as to why?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as? UITableViewCell
cell?.textLabel = "\(indexPath.row)"
return cell!
}
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
if let cell = tableView.cellForRowAtIndexPath(indexPath) as? UITableViewCell {
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark
{
cell.accessoryType = UITableViewCellAccessoryType.None
}
else
{
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
}
}
return indexPath
}