官术网_书友最值得收藏!

iOS MVC design

While creating Xcode project, you must have observed different files, such as storyboard, controller, and so on as shown in 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 Model, View, 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 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, textfields, sliders, and so on.

    Remember, View and Model do not communicate directly, they work via Controller. The following is the UI part of application that is nothing but View of application:

  • Model: 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. Model also represents the logic that manipulates and processes the data, as follows:
    NSString *password =
    [NSStringstringWithFormat:@"secret_password"];

    Here secret_password is 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. 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 will be displayed as follows:

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.

主站蜘蛛池模板: 涟源市| 永宁县| 施甸县| 三都| 女性| 陆丰市| 宜昌市| 镇江市| 肃南| 南丹县| 闸北区| 潞城市| 岑巩县| 衡南县| 宁强县| 新营市| 东源县| 延庆县| 罗田县| 彰武县| 岑巩县| 湟中县| 七台河市| 张家川| 和平区| 原平市| 江阴市| 淮阳县| 乐都县| 珲春市| 北流市| 白河县| 读书| 昔阳县| 乌拉特前旗| 古丈县| 常宁市| 南召县| 兴业县| 新乡县| 广宗县|