Swiftpack.co - jerrodputman/Reusable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jerrodputman.
jerrodputman/Reusable 1.0.1
Provides a more type-safe way of registering and dequeuing table/collection view cells.
⭐️ 0
🕓 3 years ago
iOS tvOS
.package(url: "https://github.com/jerrodputman/Reusable.git", from: "1.0.1")

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
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Basic Tests
3 years ago

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

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics