I have a table view populated with a list of files from a directory. In the following code the first click on the table returns nothing. The second click returns the label for the first cell the third click returns the label for the second click etc.
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
selectedRow = indexPath.row
let cell = self.tableView.cellForRowAtIndexPath(indexPath)
if cell != nil {
selectedFile = cell!.textLabel!.text
println("selected File \(selectedFile)")
var refreshAlert = UIAlertController(title: "Refresh", message: "Selected file \(selectedFile)", preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
println("Handle Ok logic here") }))
presentViewController(refreshAlert, animated: true, completion: nil)
}
println("did select and the text is \(cell?.textLabel?.text)")