MVVM: A Tutorial and Practical Example in Swift
MVVM rather than MVC? What are the differences, and why should we care? Here is an explanation, with a few diagrams (and an example) to help!
5 min readOct 14, 2019
MVVM was proposed by John Gossman in 2005. Interestingly the view should consist only of visual elements — and not make network calls or similar.
All architectures have advantages and disadvantages, but MVVM has become increasingly popular in implementations.
Some want a video, and here is one (it covers a slightly different example than the one in this article so they go well together!).
Prerequisites:
- Some understanding of OO terminology and practices
- Swift’s Result type is used later in the post
Terminology
Binding: The mapping of one thing to another.
View Controller: Sits between the view and the model, tying them together (usually using the…