I have a working UITableview which currently allows multiple Cells to be selected. I would like just one to be selected and if a previous one was chosen then the new selection should uncheck the previous one. Mind bender! Here is my code:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let indexPath = tableView.indexPathForSelectedRow();
let CurrentCell = tableView.cellForRowAtIndexPath(indexPath!) as UITableViewCell!;
if CurrentCell.imageView!.image == nil {
let SelectedCell = CurrentCell.textLabel!.text
CurrentCell.imageView!.image = UIImage(named:"check")!
CurrentCell.textLabel!.font = UIFont(name:"OpenSans-Bold", size:15)
println("Selected Cell is")
println(SelectedCell)
} else {
CurrentCell.imageView!.image = nil
let SelectedCell = "NothingSelected"
CurrentCell.textLabel!.font = UIFont(name:"OpenSans-Regular", size:15)
println("Nothing Selected")
}
}