Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created May 6, 2020 11:03
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/ba3ff6aab4a9fd4d5dbb13dff1dbe1d1 to your computer and use it in GitHub Desktop.
Save stevencurtis/ba3ff6aab4a9fd4d5dbb13dff1dbe1d1 to your computer and use it in GitHub Desktop.
tableViewclosure
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomTableViewCell
cell.nameLabel.text = data[indexPath.row]
cell.alertButton.tag = indexPath.row
cell.closure = {
let alert = UIAlertController(title: "Tapped Row \(indexPath.row)", message: "Thank you for tapping", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .cancel, handler: nil)
alert.addAction(action)
self.present(alert, animated: true)
}
return cell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment