IOS TOPICS

IOS Introduction
Swift UI Label
Swift UI Button
Swift UI Text Field
Swift UI Slider
Swift UI Switch
Swift UI Stepper
Swift UI Date Picker
Swift UI Segmented Control
Views
Table View
Collection Views
SCROLL VIEW
iOS Content View
iOS View Controllers
iOS Bar interface
iOS Navigation interface
iOS Architect Pattern
iOS Libraries
iOS Web request and parsing
iOS user defaults
iOS Coredata and database

Model View Presenter


Model View Presenter

The previous portion of this tutorial explored an alternative to MVC called Model View View-Model. In this design pattern, data manipulation responsibilities are handled by a new component View Model created as part of MVC. On the other hand, the view controller does much work; hence there is a lack of distribution in MVC and MVVM.

The fact that a Controller is closely tied to the lifecycle of a view makes testing a view controller a very difficult task. MVP (Model View Presenter) is another alternative design pattern that incorporates the main component presenter into the scheme of things.

MPV is a design pattern that divides items into three key components: Model, View, and Presenter. Now, the View Controller is considered a View, and the Presenter contains all of the business logic of the application's business logic reasoning logic rationale

  • View: The view consists of the View and View Controller, which are the components of the view. You'll only find the view-related code in this file. UI setup and events are taken care of by this component as well.
  • Presenter: The Presenter contains all of the application's business logic. Using delegate methods, defines the user's actions and modifies the UI accordingly. It's not UIKit-reliant, so it's easy to test.
  • Model: The application data is stored in the model. It's here that the networking calls, the parser and extensions, and the manager, take place.

Using delegates, the MVP implements a passive view pattern. In addition, it will keep track of the Presenter's actions and updates. The presenter also updates the model.