From 5ef825cadfc3c9ce04218bb39ede63cdc12800dc Mon Sep 17 00:00:00 2001 From: AleksandarSource Date: Mon, 24 Jun 2019 02:19:40 +0200 Subject: [PATCH] Update index.md (#33345) add extension for UITableViewDelegate protocol --- guide/english/swift/view-controller/index.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/guide/english/swift/view-controller/index.md b/guide/english/swift/view-controller/index.md index dbd14a8bcd..5d54312e29 100644 --- a/guide/english/swift/view-controller/index.md +++ b/guide/english/swift/view-controller/index.md @@ -71,6 +71,13 @@ This is an example of how you can add a TableView to a Basic View Controller. return data.count } } + //12 + extension ViewController: UITableViewDelegate { + //13 + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + //14 + } +} ``` 1. Define the outlet for our tableView 2. Define the data that we'll be loading into our tableView @@ -83,3 +90,6 @@ This is an example of how you can add a TableView to a Basic View Controller. 9. Return the size of our data array 10. Set the tableView's dataSource to self when the view loads 11. register the tableView's cell +12. Adds extension to ViewController class that conforms to UITableViewDelegate +13. Implement UITableViewDelegate stub for method didSelectRowAt +14. Add action when appropriate cell is selected