Skip to content

Instantly share code, notes, and snippets.

@rtking1993
Created March 30, 2018 13:44
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 rtking1993/69e4cce03241fc6f4f10c9f6d1c314de to your computer and use it in GitHub Desktop.
Save rtking1993/69e4cce03241fc6f4f10c9f6d1c314de to your computer and use it in GitHub Desktop.
Datasource methods for a UITableView
// MARK: UITableViewDataSource Methods
extension MainViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
let item = items[indexPath.row]
cell.textLabel?.text = item.item
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment