Swiftpack.co - Package - jerrodputman/Reusable

Reusable

Swift

Provides a more type-safe way of registering and dequeuing table/collection view cells.

Usage

Have your table or collection view cell class conform to Reusable.

class ExampleCell: UITableViewCell, Reusable {

    func configure(...) { ... }
}

If your cell uses a NIB for its UI, then conform to NibReusable.

class ExampleCell: UITableViewCell, NibReusable {

    func configure(...) { ... }
}

Use the register extension methods to register your cell classes with your table/collection view.

ExampleCell.registerReusableCell(for: tableView)

Use the dequeue extension methods to dequeue cells in your data source.

let cell = ExampleCell.dequeueReusableCell(for: tableView, at: indexPath)
cell.configure(...)

return cell

The cell instance is already of the correct type so there's no need to cast it in your data source.

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

Basic Tests - 2020-05-13 03:44:27

This release adds basic validation tests, along with a GitHub action to run the tests.

Initial Release - 2020-05-12 19:51:24

This is the initial release of the Reusable package.