Apple built iOS apps to use what is known as the Model View Controller (MVC), which is an architectural pattern that describes a way to structure the code in your app. In layman's terms, this just means breaking up our app into three distinct camps: Model, View, and Controller.
Here is a diagram of MVC to help you understand it:
Let's discuss each camp:
- Model: The Model camp is responsible for an app's data and business logic. The Model's only job is to handle representations of data, data storage, and the operations performed on data.
- View: The View camp is responsible for all the things that you see on the screen. The View handles presenting and formatting data that results from the user's interactions.
- Controller: The Controller camp is the liaison or coordinator between the other two camps. The Controller handles a lot of setup and connections to the View. The Controller also interprets user interactions. Since the Controller is between both the View and the Model, the View and the Model should know nothing about each other.
In summary, the Controller takes user interactions and either responds back to the View or passes it onto the Model. When the Model completes a task, it passes it back to the Controller, and then the Controller talks with the View.