iOS MVC design

While creating the Xcode project, you must have observed different files, such as storyboard, controller, and so on as shown in the following screenshot. The iOS applications are based on the Model-View-Controller (MVC) design. This concept is really useful while performing dynamic analysis of an iOS application:

 

Following is a high-level diagram of the MVC design. It mainly has three components such as ModelView, and Controller. View and Model always communicate via Controller.

 

Let's take a sample application as shown in the following that takes user input as a password, checks with the backend value, and displays whether the password is correct or incorrect.

 

  • View: View displays the information that is contained in the Model. The UIkit framework contains classes to draw typical interface elements such as tables (lists), buttons, text fields, sliders, and so on.
  • Remember, View and Model do not communicate directly, they work via Controller. The following is the UI part of the application that is nothing but View of application:

Model: The model contains the data. The Model objects obtain the data either from a database or the files that could be located locally or externally. The data can be obtained from hardcoded values or web services. The model also represents the logic that manipulates and processes the data, as follows:

NSString *password =
[NSStringstringWithFormat:@"secret_password"];

  • Here secret_password is the hardcoded value that is nothing but Model.
  • Controller: It acts as a mediator between Model and View. Now, here Enter Password is an action. So, whenever the user enters the password from View and hits enter, the request goes to Controller that checks the data in Model and if the password does not match, it informs the Controller and then Controller notifies it to View.  ios app development course 

 

  • Controller asks Model to validate the user password and once it gets the response from Model, it will notify the View whether the user has entered the correct password or not. Hence, View shows the Incorrect Password message, as shown in the following screenshot:

Now, if the data entered in View matches with the data in Model, then the message. ios swift Course

 

So, if you have observed, all communication happens through Controller. Now you are proficient with some basics about iOS developments. Let's study iOS security concepts from basics.

 

Started by meenati biswal at October 25, 2019 - 5:29 AM