Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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