Let's apply what we learned in the previous episodes to the week view controller. The week view controller currently configures the cells of its table view. That is something we want to change. The refactoring of the week view controller involves four steps. We create a view model for each table view cell. The WeekViewModel
struct generates a view model for each table view cell. We define a protocol to which the view models for the table view cells conform. The WeatherDayTableViewCell
class has the ability to configure itself using a view model.
Subscribe to Cocoacasts Plus to watch this episode.
Mastering MVVM With Swift
Supercharging MVVM With Protocols
by Bart Jacobs in Model-View-ViewModel
Swift 5
Xcode 11
iOS 13
Mastering MVVM With Swift
-
07:46
-
03:43
-
02:32
-
08:03
-
05:05
-
08:08
-
10 Using MVVM In the Settings View
06:56
-
11 Adding Protocols to the Mix
04:05
-
13 Supercharging MVVM With Protocols
06:26
-
02:47
-
15 Testing Your First View Model
07:59
-
16 Using Stubs for Better Unit Tests
08:17
-
04:07
-
18 Taking MVVM to the Next Level
05:28
-
03:08
-
20 DIY Bindings
08:21
-
22 Why RxSwift
02:01
-
23 Integrating RxSwift and RxCocoa
02:02
-
26 Why Combine
03:51
-
31 Testing and Mocking (RxSwift)
08:28
-
32 Testing and Mocking (Combine)
09:08