ReusableKit
ReusableKit copied to clipboard
Create generic getAll methods to register cells.
I am trying to build generic getAll method will which just return instances of Reusable cells.
By creating that I don't have to register the cells manually I can just add it to the array and in the registerCellsFromReusable() it will be registered.
enum Reusable {
static let listOptionTableCell = ReusableCell<ListOptionTableCell>(nibName: "ListOptionTableCell")
static let seperatorTableCell = ReusableCell<SeperatorTableCell>(nibName: "SeperatorTableCell")
static func getAll<T>() -> [ReusableCell<T>] where T : UITableViewCell {
return [listOptionTableCell, seperatorTableCell]
}
}
override func viewDidLoad() {
super.viewDidLoad()
registerCellsFromReusable()
}
private func registerCellsFromReusable() {
Reusable.getAll().forEach { tableView.register($0) }
}
Cool stuff but I don't know why I am getting the below issue even though ListOptionTableCell & SeperatorTableCell inherits from UITableViewCell
