|
|
||
|---|---|---|
| TableKit | ||
| TableKit.xcworkspace | ||
| TableKitDemo | ||
| Tests | ||
| .gitignore | ||
| .travis.yml | ||
| LICENSE | ||
| README.md | ||
| TableKit.podspec | ||
README.md
#TableKit
TableKit is a super lightweight yet powerful generic library that handles a complexity of UITableView's datasource and delegate methods in a Swifty way. TableKit's goal is to provide the easiest way to create complex table views. With TableKit you don't have to write a messy code of switch or if statements when you deal with bunch of different cells in different sections.
Features
- Type-safe cells based on generics
- The easiest way to map your models or view models to cells
- Correctly handles autolayout cells with multiline labels
- Chainable cell actions (select/deselect etc.)
- Support cells created from code, xib, or storyboard
- Automatic xib/classes registration
- No need to subclass
- Extensibility
- Tests
Usage
Create your rows:
let row1 = TableRow<String, StringTableViewCell>(item: "1")
let row2 = TableRow<String, IntTableViewCell>(item: 2)
let row3 = TableRow<String, FloatTableViewCell>(item: 3.0)
Put rows into section:
let s = TableSection(rows: [row1, row2, row3])
And configure your table:
let tableDirector = TableDirector(tableView: tableView)
tableDirector += section
Done. Your table is ready. You may want to look at your cell. It has to conform to ConfigurableCell protocol:
class StringTableViewCell: UITableViewCell, ConfigurableCell {
typealias T = String
func configure(string: T) {
titleLabel.text = string
}
static func estimatedHeight() -> CGFloat {
return 44
}
}
License
TableKit is available under the MIT license. See LICENSE for details.