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

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.

主站蜘蛛池模板: 耒阳市| 田东县| 乌鲁木齐县| 嘉黎县| 工布江达县| 呈贡县| 崇仁县| 陵川县| 凤庆县| 珠海市| 三门县| 高陵县| 太仆寺旗| 五家渠市| 禹州市| 九龙坡区| 景宁| 河津市| 江永县| 彰武县| 稻城县| 乌审旗| 嘉禾县| 宜州市| 博白县| 徐闻县| 永川市| 博白县| 柘城县| 时尚| 浦东新区| 嫩江县| 邢台市| 安平县| 锡林郭勒盟| 涿鹿县| 仲巴县| 邻水| 洛宁县| 阿尔山市| 中阳县|