---
title: "#74: Static 📺"
url: https://littlebitesofcocoa.com/74-static
author: Jake Marsh
published: 2015-09-03
topics: ["Libraries","Table Views"]
description: "Static is a library from Venmo that makes it very simple to create simple static-content table views. Let's take a look at how to use it: The basic idea of..."
---

# #74: Static 📺

By Jake Marsh, September 3, 2015. HTML: https://littlebitesofcocoa.com/74-static

[Static](http://git.io/statictv) is a library from [Venmo](https://github.com/venmo) that makes it very simple to create simple static-content **table views**. Let's take a look at how to use it:

The basic idea of **Static** is that we'll configure what is displayed in our **table view** by supplying **Section** and **Row** objects to a **DataSource** object:

``` swift
class SettingsViewController: TableViewController {
    override func viewDidLoad() {
    super.viewDidLoad()

    dataSource.sections = [
      Section(rows: [
        Row(text: "Jake Marsh", detailText: "@jakemarsh",
          cellClass: SubtitleCell.self,
          selection: { [unowned self] in
            // edit profile
          }
        ),
        Row(
          text: "Cellular Downloads",
          accessory: .View(cellularDownloadsSwitch)
        )],
        footer: .Title("Version: \(appVersion)")
      )
    ]
  }
}
```

Custom **accessories** are simple to implement with **Static**:

``` swift
Row(text: "Enable Hyperdrive", accessory: .DetailButton({
  // configure hyperdrive settings
})),
```

Note how we not only give the **cell** a **detail button**, but we pass in a **closure** to be run when the **detail button** is tapped. We can even use a custom **UIView** as an **accessory** like we did with the **switch** in our first example.

We used a simple **string** as our **footer** here, but we can easily use a **view** instead:

``` swift
Section(rows: [], footer: .View(footerView)).
```

Static does a great job separating concerns. **Rows** don't know anything about the actual **UITableViewCells** that eventually get shown to represent them. **Static** uses the `.Value1` cell type by default and comes with a few other  standard **cell types**. We can easily add our own by implementing the **CellType** protocol on any of our own **UITableViewCell** subclasses.

More info about **Static** can be found at [git.io/statictv](http://git.io/statictv)
