When I run this code and tap on a cell it always puts the checkmark on the bottom most cell, if I scroll the table view up and down it puts it on the top most cell. Any ideas?
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return resultsArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
cell = tableView.dequeueReusableCellWithIdentifier("Cell") as? UITableViewCell
if (cell != nil) {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
}
cell?.textLabel?.text = resultsArray[indexPath.row] as? String
return cell!
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
println(indexPath.row)
if cell?.accessoryType != UITableViewCellAccessoryType.Checkmark {
cell?.accessoryType = UITableViewCellAccessoryType.Checkmark
} else if cell?.accessoryType == UITableViewCellAccessoryType.Checkmark {
cell?.accessoryType = UITableViewCellAccessoryType.None
}
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}