Created
May 3, 2017 05:35
-
-
Save d-date/5cfd6b17763612297a439976d8dd1cee to your computer and use it in GitHub Desktop.
Genericsを使えばほーらこんな単純に… #CodePiece
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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