Last active
February 16, 2020 16:14
-
-
Save yzhong52/6744fe5301856a5abf266f416af0a7e2 to your computer and use it in GitHub Desktop.
Building a Client App From Scratch (UITableViewDataSource)
This file contains 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
extension ViewController: UITableViewDataSource { | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return articles.count | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let tableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) | |
let article = articles[indexPath.row] | |
tableViewCell.textLabel?.text = article.title | |
return tableViewCell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment