Michael Long
Jun 25, 2022

--

Does every view need a view model? Nope. Do most views need a view model? Probably not.

But do view models solve problems in views with complex I/O, business logic, or data manipulation?

Yes. And that's especially important when you want to do unit tests to ensure that your model (and as such, your view) is correct.

See:

https://betterprogramming.pub/swiftui-choosing-an-application-architecture-6ec9289f8e8f

https://betterprogramming.pub/swiftui-view-models-are-not-protocols-8c415c0325b1

https://betterprogramming.pub/writing-testable-views-in-swiftui-ba28baec6a32

--

--

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