Skip to content

Instantly share code, notes, and snippets.

@tsraveling
Last active June 13, 2019 19:41
Show Gist options
  • Save tsraveling/1dd6f69482d30a87fce06b27e5e00c7c to your computer and use it in GitHub Desktop.
Save tsraveling/1dd6f69482d30a87fce06b27e5e00c7c to your computer and use it in GitHub Desktop.
UITableView delegate and datasource
// MARK: - TableView delegate and datasource
extension SomeClass: UITableViewDataSource, UITableViewDelegate {
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
return cell
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 1
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return false
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .destructive, title: "Delete") { action, path in
}
let edit = UITableViewRowAction(style: .normal, title: "Edit") { (action, path) in
}
return [edit,delete]
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment