Mobile Development

Model - View - Controller

iOS templates new projects in Xcode using the MVC pattern. That is to say, they give you a separate entity for each part of the MVC pattern. Keeping each part of MVC as separate as possible allows for reusability, maintenance and clean code.

The above diagram illustrates the MVC pattern and is broken out into model, view and controller and linked between them is the action. See reference [1].

This chapter will be exploring the following topics:

  1. Model - Data storage
  2. View - UI as defined and created in a Storyboard
  3. Controller - Controller classes which typically override a UIKit class.

[Video] Introduction to MVC

The following video serves as an introduction to the MVC pattern and provides a helpful overview of the concept.

Introduction to MVC


A model in an iOS application can be a simple class or struct that persists in memory. It can also be a file that is written to disk, which would presist through subsequent launches of your application. CoreData is a system that Apple provides as a robust model layer in your iOS applications.

Model objects encapsulate the data specific to an application and define the logic and computation that manipulate and process that data. [1]



Views are typically handled in a Storyboard, handled by Interface Builder within Xcode.

A view object is an object in an application that users can see. A view object knows how to draw itself and can respond to user actions. [1]


Deciding what to do once your user interacts with your application is handled by the controller. In your projects, this is the subclass of UIViewControllers, UITableViewControllers, etc.

A controller object acts as an intermediary between one or more of an application’s view objects and one or more of its model objects. Controller objects are thus a conduit through which view objects learn about changes in model objects and vice versa. [1]



[1] - Cocoa Core - Model View Controller

[2] Start Developing iOS apps today - Using Design Patterns