Created
September 27, 2015 05:41
-
-
Save cdl/4a0b7423167efc7264f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Aiming to print out the value of a cell's text label when tapped. Assume the below | |
// method is inside the implementation of a UITableViewController subclass. | |
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
let cell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) | |
guard let _ = cell where cell != nil else { | |
return | |
} | |
tableView.deselectRowAtIndexPath(indexPath, animated: true) | |
print("Tapped cell with label:", cell!.textLabel?.text) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
guard
is basicallyif
but theelse
block has to return, break, or continue.