Skip to content

Instantly share code, notes, and snippets.

@efremidze
Created July 21, 2017 22:29
Show Gist options
  • Save efremidze/1ba21c1eeb97381e41455e68641da2ec to your computer and use it in GitHub Desktop.
Save efremidze/1ba21c1eeb97381e41455e68641da2ec to your computer and use it in GitHub Desktop.
UITableView reusable cell block
extension UITableView {
func reusableCell(style: UITableViewCellStyle, reuseIdentifier: String, configureBlock: ((UITableViewCell) -> Void)? = nil) -> UITableViewCell {
if let cell = dequeueReusableCell(withIdentifier: reuseIdentifier) {
configureBlock?(cell)
return cell
}
return UITableViewCell(style: style, reuseIdentifier: reuseIdentifier)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment