Skip to content

Instantly share code, notes, and snippets.

@hmlongco
Last active August 1, 2021 18:15
Show Gist options
  • Save hmlongco/09b0cb837b7ef6389ee0feb2c623592a to your computer and use it in GitHub Desktop.
Save hmlongco/09b0cb837b7ef6389ee0feb2c623592a to your computer and use it in GitHub Desktop.
The tableview extension
extension UITableView {
func dequeueCell<Cell:UITableViewCell>(_ id: String, for indexPath: IndexPath, configure: (_ cell: Cell) -> Void) -> UITableViewCell {
let cell = dequeueReusableCell(withIdentifier: id, for: indexPath)
if let cell = cell as? Cell {
configure(cell)
}
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment