Model-view-controller
MVC separates the onscreen object looks from the IT behaves. A onscreen button (the view) has no intrinsic meaning. It ' s just a button that users can push. That view ' s controller acts as an intermediary. It connects user interactions such as button taps to targeted methods in your application, which is the model. The application supplies and stores meaningful data and responds to interactions such as these button taps by producing so Me sort of useful result.
Each MVC element works separately. You might swap out a push button with, for example, a toggle switch without changing your model or controller. The program con-tinues to work as before, and the GUI now have a different look. Alternatively, you might leave the interface as are and change your application where a button triggers a different kind of Response in your model. Separating these elements enables the build Main-tainable program, the can be updated independently.
The MVC paradigm on the IPhone breaks to the following categories:
@ View. View components is provided by children of the UIView class and by its associated (and somewhat misnamed) Uiviewcontrolle R class.
@Controller. The controller behavior is implemented through three key technolo-gies:delegation, target-action, and notification.
@Model. Model methods supply data through protocols such as data sourcing and meaning by implementing callback methods triggered B Y the controller.
Together these three elements form the backbone of the MVC programming Para-digm. Let's look at all of these elements of the IPhone MVC design pattern in a bit more detail. The following sections introduce each element and its supporting classes.
Model-view-controller
MVC separates the object that is displayed on the screen and its behavior. A button on the screen (view) has no practical meaning, it's just a button that a user can click. The view's controller (the controllers of the views) plays an intermediary role. Model connects user interaction, such as clicking the button in your program to the target method. The application provides and stores meaningful data and responds to user interactions such as a series of user data generated by a button click.
Every element of MVC works separately. You can replace the push button with a toggle switch without changing your model and controller. The program still runs the same way as before, but there are some different things that appear in the interface. Or you can change the response of the button in your program without changing the interface. Separating these elements allows you to create a maintainable, rapidly updated program element.
The MVC example class in the iphone:
The @ View view element is provided by the UIView class and its associated Uiviewcontroler classes and their subclasses.
The implementation of @Conreoller controller behavior is through three key technologies: Delegation,target-action,notification.
The @Model Model method provides data through protocols, such as providing the data source and meaning by implementing a callback method triggered by the controller.
Model-view-controller (The IPhone Developer ' s Cookbook)