stevenA
stevenA

Reputation: 103

Creating Method for UI Notification in Swift

In one of my views, I have a UITableView. I would like to create a function that is called whenever a user selects a cell in the table. I figure I should use "UITableViewSelectionDidChangeNotification", but I am new to iOS and Swift so I don't know how to precede.

Thanks for your help!

Upvotes: 0

Views: 333

Answers (1)

Guled
Guled

Reputation: 679

This is the function you are looking for:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        // The row that I clicked on
        println(indexPath.row)
  }

Did you add the delegate and protocol of a tableview to your viewcontroller and connect the tableview properly? If so the function above should work for you. If not, I can help you out.

Also, here are some resources that I found useful for myself online:

https://www.youtube.com/results?search_query=swift+tableview

Upvotes: 1

Related Questions