Model-View-Controller

MVC is a software design pattern that decomposes an application into three parts: the Model, the View, and the Controller. MVC is the strategy of choice in Cocoa, and is particularly good practice for GUI applications.

Model The data, and the rules that govern reading and writing this data.
View The presentation of the data.
Controller The logic that makes it all happen.

Communication

  • Controllers can always talk directly to their Model and to their View.
  • The Model and View should never speak to each other.
  • The View communicate with the Controller "blindlyā€¯:
    • The Controller drops a target onto itself.
    • The Controller hands out an action to the View.
    • The View sends the action when something happens in the UI.
  • The View does not “own” the data that it displays, it acquires it from the Controller, which interprets/formats Model data for that specific View.
  • If the Model has data to update, it broadcasts this information, and the Controller can tune into this broadcast.

Don’t worry if this is confusing for now, it will make more sense once we start working with it concretely. Just remember that the Model and the View should never communicate directly.


  1. Paul Hegarty. Lecture 1 Slides. iPad and iPhone Application Development. Stanford, Nov 14 2011.

  2. Model-view-controller. Wikipedia, Aug 30 2012.

  3. Nadir Gulzar. Fast Track to Struts: What it Does and How. TheServerSide.com, Nov 1 2002.

Comments are closed.