Michael Long
Nov 21, 2023

--

As I covered, you don't swap out the view model, you swap out the dependencies on which the view model is based (loader in this example).

Doing so allows your previews to test and exercise your actual view model code. If you swap out your entire VM, then you can test your view, but you have no idea if your VM's logic is correct or contains hidden issues.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet