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.|
- 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.