Speaking of MVVM, I had to start with MVC.
MVC (Model-view-controller)
Model models: used to render data
View view: Used to render the user interface
Controller controllers: Used to adjust the interaction between the model and the view.
The problem with the growing weight-level view controller in IOS apps. In a typical MVC application, Many logic is placed in the View Controller.
Some of them do belong to the View Controller, but more so-called "presentation logic" (presentation logics);
In order to keep the controller growing and easy to test management, MVVM appears.
MVVM: It's actually an enhanced version of MVC and moves the presentation logic out of the Controller and into a new object, the View Model
The motivation for using MVVM on IOS is to let it reduce the complexity of the View Controller and make the presentation logic easier to test
ViewModel: It is between View/controller and Model.
Model layer:
ViewMode Layer:
Controller layer:
IOS-MVVM design mode