iPhone SDK: MVC in iPhone Application Development

Controller | IOS | IPhone | Model | Mvc | View

iPhone Application Development


This entry is part 6 of 9 in the series iPhone Application Development

As you probably know MVC is not something that exists just for the iPhone Application Development. MVC is a software design pattern. You can do this in java, c#, web or desktop applications. Core of MVC is to rip your data and your user interface apart. You should be able to change one without affecting other.

iPhone Application & MVC

Model part of MVC is your data and your class that represent your data weather that’s 1 class or more. View is your interface, what the user actually sees. Controller is the glue that hooks one code to the other. In iPhone Application Development, View is the easiest to understand, you making your view in interface builder and not writing code there. View never talks to the Model directly. They are always going through this glue code in the middle. The Controller talks to the Model and The Controller talks to the View.

iphone application development

For Example, we create user interface with 2 labels, a text box and a button. We have to define very specifically the connections between view and the controller code. You can’t do what you might be do in the other environments, which is drag a button, double click it and write code. It doesn’t work that way. Instead we have our view very separate from the code and we have to define our button is being an action; it causes code to happen in the controller. On flip side of that, we have to define our text field as being outlet. We have to reach from our code into text field. We have to reach from our code into label.

Action: something in the view causes code to happen in the controller.

Outlet: something in the controller affects the view. (We will create one outlet in our next example)

We can create simple iPhone application like this without using model but we will see models later on.

Series Navigation<< iPhone SDK: Using Existing Objective-C ClassesiOS: Working with Actions & Outlets >>

Bookmark Link using: bookmark at folkd