TableViewTools 0.0.8

TableViewTools 0.0.8

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2018
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Dmitry Frishbuter, Nikita Ermolenko.



  • By
  • Dmitry Frishbuter

TableViewTools

Overview

This repo contains the powerful tool for making your UITableView usage simply and comfortable! It allows you to move your UITableView configuration logic to separated objects, such as inheritors of TableViewSectionItemProtocol and TableViewCellItemProtocol, and simply register, add and remove cells from your table view.

Example

To run the example project, run pod try, or simply clone the repo and open project Example-iOS.

Requirements


Basic usage

Creating manager

    manager = TableViewManager(tableView: tableView)

Creating section

    let titles = ["Item 1", "Item 2", "Item 3"]
    var cellItems = [ExampleTableViewCellItem]()
    titles.forEach { title in
        let cellItem = ExampleTableViewCellItem(title: title)
        cellItems.append(cellItem)
    }

    let sectionItem = TableViewSectionItem(cellItems: cellItems)
    manager.sectionItems = [sectionItem]

Cell item implementation

For basic usage, inside cell item should be implemented these entries from TableViewCellItemProtocol:

    class ExampleTableViewCellItem: TableViewCellItemProtocol {

        var reuseType: ReuseType {
            return ReuseType(cellClass: ExampleTableViewCell.self)
        }

        func height(in tableView: UITableView) -> CGFloat {
            return 100
        }

        func cellForTableView(tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
            let cell: ExampleTableViewCell = tableView.dequeueReusableCell()
            return cell
        }
    }

Authors

License

TableViewTools is available under the MIT license. See the LICENSE file for more info.