How to Couple UITableView Cell Identifiers and View Models
Rui Peres proposes to make UITableViewCell
view models the topmost model data. Traditionally, Cocoa developers stored something in arrays that corresponded to the indexPath
of a cell. In principle, this qualifies as “model” data already, but it’s not yet a view model. In practice, it can even be something different than a view model entirely – and make your view controllers slimmer!
Separate Read Model from Write Model to Support Complex Forms
One thing that repeatedly messes up the conceptual purity of a view model is figuring out which entity should be mutated upon user interaction. Part of this purity stems from the fact that a view model is best served as view data to stress that it doesn’t contain much (business) logic. Making the data mutable introduces a lot of problems figuring out what that view model really is.
Yelp's Modular UITableViews
Yelp reuses a setup of modular table views across their huge app. A simple timeline entry can be composed of 5 cells, each with its own model representation. These cells are used to create various component setups. What I find most interesting is the combination of registering cells for reuse identifiers in one place and using reuseIdentifierForCellAtIndexPath
in another.
Extract UITableView Contents and Configuration Into Helpers
In a top secret project I am working on, I think I found a consistent way to create UITableViewController
s in a reusable fashion without making a mess with massive view controllers. The key ingredient is, as always, delegation from the view controller and thus composing larger components:
Presenter and MVVM for UITableViews?
When I wrote about MVVM with a “control” which really was a presenter, the view in question displayed some kind of data. Any sufficiently complex view would do, but the example focused on a view controller which consisted of a single composite view. UITableViewController
s are a different kind of beast, though.
Library for Providing Static UITableView Contents in Swift
I discovered a Swift library called Static the other day. It helps set up and fill UITableView
s with static content – that is, it doesn’t permit deletion or rearrangement of new rows into the table. I think the following example to configure sections with rows reads really nice: