How does the Model-View-Controller pattern apply to iPhone development?

I recently looked at the MVC pattern and wanted to apply it to iPhone development. However, there seem to be so many variations on the template that I'm not sure exactly how it should be applied.

As I understand it, the view will notify the controller of any actions that have been performed, and the controller, in turn, will update the data model (if necessary). The data model will notify the view whenever a data change occurs, and the view then updates its display accordingly.

In this basic model, the controller has only knowledge of the data model. However, I cannot figure out how to use this design in my iPhone application.

On the next page, an alternative version of the template is proposed, in which the controller has an idea of ​​the data model and presentation, and all communication between the model and the representation is done through the controller. It also appears that the model and view have access to the controller. Will I be right in suggesting that the data model interacts with the controller through some form of notification (notifications or KVO) and that the view interacts with the controller through actions?

Is this second model correct?

http://www.bogotobogo.com/DesignPatterns/mvc_model_view_controller_pattern.html

Many thanks,

Danny

+5
source share
4 answers

Paul Hegartys MVC iOS . . Stanford iTunes U. MVC 22.


, . 1. Cocoa Touch, Objective-C, MVC (21 2010 .)

+6

MVC , ( ). , MVC, , .

, Apple MVC. Cocoa Design Patterns , SDK ( MVCNetworking).

iOS ViewControllers ( , ).

, MVC .

+2

iOS MVC.

viewControllers . Interface Builder, , .

, Cocoa -Touch "" - , , .

MVC , , . iOS, .

viewController /, KVO , .

, Apple, . , MVC, , , , .

+1

-, . . , . . , , .

:

  • , . . .
  • , .

In iOS, UIView is a completely passive view. In most cases, the entire main mutation has always been performed from outside the UViewController. And the model part should be fully implemented as you want. (Or you can integrate models into the controller if it is small enough, however I do not recommend it)

In some big feature of UIView, MVC patterns are used under the scale. Fractal!

+1
source

All Articles