Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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