Skip to content

Instantly share code, notes, and snippets.

@paigeshin
Last active June 29, 2022 06:50
Show Gist options
  • Select an option

  • Save paigeshin/1810a211da7b22e3258b7ef9e88366f0 to your computer and use it in GitHub Desktop.

Select an option

Save paigeshin/1810a211da7b22e3258b7ef9e88366f0 to your computer and use it in GitHub Desktop.
extension UITableView {
func register(_ type: UITableViewCell.Type) {
let className = String(describing: type)
register(UINib(nibName: className, bundle: nil), forCellReuseIdentifier: className)
}
func dequeueReusableCell<T>(_ type: T.Type) -> T? {
let className = String(describing: type)
return dequeueReusableCell(withIdentifier: className) as? T
}
}
tableView.register(MyCell.self)
tableView.dequeueReusableCell(MyCell.self)!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment