- July 26, 2025
- Mins Read
Simple view controller that provides a way to configure a table view with multiple types of cells while keeping type safety. To learn what and whys I encourage you to read the associated blog post.
Let’s say we want to present a table view controller with four rows: two with text and two with images. We start by creating view data structures that cells will be configurable with:
struct TextCellViewData {
let title: String
}
struct ImageCellViewData {
let image: UIImage
}
and the cells themselves:
class TextTableViewCell: UITableViewCell {
func updateWithViewData(viewData: TextCellViewData) {
textLabel?.text = viewData.title
}
}
class ImageTableViewCell: UITableViewCell {
func updateWithViewData(viewData: ImageCellViewData) {
imageView?.image = viewData.image
}
}
Now to present a table view controller with those cells, we simply configure it in the following way:
import ConfigurableTableViewController
…
let viewController = ConfigurableTableViewController(items: [
CellConfigurator<TextTableViewCell>(viewData: TextCellViewData(title: “Foo”)),
CellConfigurator<ImageTableViewCell>(viewData: ImageCellViewData(image: apple)),
CellConfigurator<ImageTableViewCell>(viewData: ImageCellViewData(image: google)),
CellConfigurator<TextTableViewCell>(viewData: TextCellViewData(title: “Bar”)),
])
presentViewController(viewController, animated: true, completion: nil)
And ta-da 🎈:
I encourage you to check both the implementation and an example app.
To run the example project; clone the repo, open the project and run ExampleApp
target.
iOS 8 and above.
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...