Created
July 1, 2020 15:54
-
-
Save AlexPinhasov/1b5caabeb1c50cda4caf063b188a3b44 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class TableViewCellGenerator<T: UITableViewCell> { | |
// Class func - We need to override since each cell uses different objects to populate it self | |
class func configure(cell: UITableViewCell, using object: Any?, at indexPath: IndexPath) {} | |
// Static func - Should not be overriden since we use generics here | |
static func cell(for indexPath: IndexPath, inTableView tableView: UITableView) -> UITableViewCell { | |
return tableView.dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) | |
} | |
static func registerReuseIdentifier(for tableView: UITableView) { | |
tableView.register(T.nibName, forCellReuseIdentifier: T.reuseIdentifier) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment