- Makes dequeuing cells simpler
- Supports UITableView and UICollectionView
- Supports UITableViewCell and UICollectionViewCell
- SPM:
.package(url: "https://github.com/eonist/ReusableCell", .branch("master"))
import ReusableCell_iOS
tableView.register(CustomCell.self) // Register Cells with ease
extension CustomCell: ReusableCell {} // Make your custom cells
let cell: CustomCell = tableView.dequeueReusableCell(for: indexPath) // Instantiate your cells
// In the cell:
extension CustomCell: ReusableCellKind { // make your subclass conform to the protocol
open class var defaultReuseIdentifier: String { return "\(TextCell.self)" }
}
import CommonCell
import With
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return with(tableView.dequeueReusableCell(indexPath: indexPath) as TextCell) {
$0.backgroundColor = .clear
$0.data = rowData[indexPath.row] // populate cell with data
}
}