Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created May 25, 2020 07: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 stevencurtis/6cce360cf8c20d7d7d6d74d7e23c511b to your computer and use it in GitHub Desktop.
Save stevencurtis/6cce360cf8c20d7d7d6d74d7e23c511b to your computer and use it in GitHub Desktop.
tabledatasource
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == firstTable {
return firstData.count
}
return secondData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == firstTable {
let cell = firstTable.dequeueReusableCell(withIdentifier: "firstcell", for: indexPath)
cell.textLabel?.text = firstData[indexPath.row].description
return cell
} else {
let cell = secondTable.dequeueReusableCell(withIdentifier: "secondcell", for: indexPath)
cell.textLabel?.text = secondData[indexPath.row]
return cell
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment