MVVM Architecture in iOS

View Controller: It only performs UI related stuff. It get data from View Model and show in UI. On user’s inputs View Model to make API call to get required data for views.

View Model: It is most important component of this architecture. It provides required data to views from Model. View Model never knows what the view is or what the view does. This makes this architecture more testable and removes complexity from the view.

Model: The Model represents simple model of data. It simply holds the data and has nothing to do with business logic. You can simply say it’s a plain structure of data that we are expecting from our API.

MVVMPattern.png

API Service: This class is a simple class where we are fetching data using URLSession class. you can use any networking model here to fetch data from your server. From our view model class, we will call the API Service class

Network Service: This is where the actual URL Session will make API call, it is called by API Service class to make network Call for View Model to provide data in views.