O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Model-View-Controller

Model-View-Controller, or MVC, is a design pattern that is based on the idea that any class 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required