Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How is uiviewcontroller used in the mvvm pattern?


Asked by Jace Hoover on Dec 13, 2021 FAQ



Since UIViewController is supposed to be a Controller in the MVC pattern, and it’s already doing a lot with the Views, we can merge them into the View of our new pattern - MVVM. In the MVVM design pattern, Model is the same as in MVC pattern. It represents simple data.
Consequently,
Before diving in the code, here is a quick introduction to this pattern. MVVM stands for Model, View, ViewModel, a specific architecture pattern where the ViewModel stands between View and Model providing interfaces to imitate UI component. This connection is made by “binding” values, linking logical data to the UI.
Thereof, The View Model is a key piece of MVVM pattern. View model acts as a bridge between the view and the model. Each view class has a corresponding view model where it gets its data from. View model retieves data from the model, manipulates the data into a format required by the view, and notifies the view to show this data.
In addition,
Here is the architecture of MVVM: In the MVVM design pattern, view and controller are closely coupled together and treated as one component. It can also be represented as UIView or UIViewController objects, accompanied by their .xib and .storyboard files.
Just so,
View Controllers manage UIView s and other UIViewController s. An iOS application has a single window, but many screens, each of which may contain several UIView s. Managing those screens is complex and requires responding to both user input and changes in the model (problem domain).