Model-View-Controller

Model-View-Controller, or MVC, is a design pattern that is based on the idea that any class that you create should fall into one of three job categories: model, view, or controller. Here is a breakdown of the division of labor:

  • Models are responsible for storing data and making it available to other objects. Models have no knowledge of the user interface or how to draw themselves on the screen. Their sole purpose is holding and managing data. For example, an application that tracks attendance for a school would define a model object for Student. A Student would “model” all of the attributes a real student would have, such as a name and a grade. Swift types like String and Array are traditional building blocks ...

Get Swift Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.