Latest 0.4.4
License MIT
Platforms ios 9.0

CI Status


To run the example project, clone the repo, and run pod install from the Example directory first.


  • Swift 4.0
  • iOS 9.0


PluggableTableView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'PluggableTableView'


Showing a list is something you can see in almost every app. PluggableTableView becomes handy if you want to show a simple list that should be extendable and clean.
You can add all kinds of cells, headers and footers by just providing a specific view model. View Models seperates business logic from the controller and can easily be tested. This configuration is open for extendability and close for modification.


  • [x] Support view models for a table view.
  • [x] Automatic registration of cell types and header / footer views.
  • [x] Support auto sizing cells and non-auto sizing cells.
  • [x] Support xib cells.
  • [ ] Support non-xib cells.


Setup the view

import PluggableTableView

class ViewController: UIViewController
    @IBOutlet weak var tableView: PluggableTableView!

    override func viewDidLoad() {
        tableView.autoSizingEnabled = true
        tableView.pluggableDataSource = self

extension ViewController: PluggableTableViewDataSource
    func pluggableSections() -> [PluggableTableSection] {
        //TODO: Needs to be implemented

Create view models

Create a section view model that specifies which header / footer and cells to show.

class DefaultSection: PluggableTableSection
    let header: PluggableTableHeaderFooter?
    let viewModels: [PluggableTableViewModel]
    let footer: PluggableTableHeaderFooter?

    init(viewModels: [PluggableTableViewModel], header: PluggableTableHeaderFooter? = nil, footer: PluggableTableHeaderFooter? = nil) {
        self.viewModels = viewModels
        self.header = header
        self.footer = footer

Then you only need to specify your cell view model, which can be literally anything. Below just an example.

class CellTitleViewModel: PluggableTableViewModel
    typealias C = YourTitleCell

    let model: Model // The model you want to map to this view model.
    var cellType: UITableViewCell.Type = C.self

    init(model: Model) {
        self.model = model

    func cell(from tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: cellType.identifier, for: indexPath) as! C
        cell.title = "(model.title) (model.something)"
        return cell

    func height(for width: CGFloat) -> CGFloat? { 
        // We return `nil` here because the cell has been setup for auto-sizing.
        return nil

Provide data to table view

import PluggableTableView

class ViewController: UIViewController
    // Configure the view..

extension ViewController: PluggableTableViewDataSource
    func pluggableSections() -> [PluggableTableSection] {
        let viewModels ={ CellTitleViewModel(model: $0) })
        let singleSection = DefaultSection(viewModels: viewModels) 
        return [singleSection]


NielsKoole, [email protected]


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

Latest podspec

    "name": "PluggableTableView",
    "version": "0.4.4",
    "summary": "PluggableTableView provides a TableView to work easily with View Models.",
    "description": "PluggableTableView provides an UITableView that does all the work for you. The only thing you need to do is provide a list of view models.nThe registration of the cells, headers and footers will be done automatically.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "NielsKoole": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.4.4"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "ios": {
        "source_files": "PluggableTableView/Classes/**/*"

Pin It on Pinterest

Share This