Understanding the Model-View-Controller design pattern
The Model-View-Controller (MVC) design pattern is a common approach used to build iOS apps. MVC divides an app into three different parts:
- Model: This handles data storage and representation, and data processing tasks.
- View: This includes all the things that are on the screen that the user can interact with.
- Controller: This manages the flow of information between model and view.
One notable feature of MVC is that view and model do not interact with one another; instead, all communication is managed by the controller.
For example, imagine you're at a restaurant. You look at a menu and choose something you want. Then, a waiter comes, takes your order, and sends it to the cook. The cook prepares your order, and, when it is done, the waiter takes the order and brings it out to you. In this scenario, the menu is the view, the waiter is the controller, and the cook is the model. Also, note that all interactions...