Skip to content

Instantly share code, notes, and snippets.

@yzhong52
Last active February 16, 2020 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yzhong52/6744fe5301856a5abf266f416af0a7e2 to your computer and use it in GitHub Desktop.
Save yzhong52/6744fe5301856a5abf266f416af0a7e2 to your computer and use it in GitHub Desktop.
Building a Client App From Scratch (UITableViewDataSource)
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