Skip to content

Instantly share code, notes, and snippets.

@d-date
Created May 3, 2017 05:35
Show Gist options
  • Save d-date/5cfd6b17763612297a439976d8dd1cee to your computer and use it in GitHub Desktop.
Save d-date/5cfd6b17763612297a439976d8dd1cee to your computer and use it in GitHub Desktop.
Genericsを使えばほーらこんな単純に… #CodePiece
extension UITableView {
func register<Cell: UITableViewCell>(for cell: Cell) {
let nib = UINib(nibName: cell.className(), bundle: nil)
register(nib, forCellReuseIdentifier: cell.className())
}
func dequeueReusableCell<Cell: UITableViewCell>(for indexPath: IndexPath) -> Cell {
return dequeueReusableCell(withIdentifier: Cell.className(), for: indexPath) as! Cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment