A pure MVC example
Without further ado, let's implement a small program using this architectural pattern. It will be a command-line tool independent of AppKit or UIKit.
We'll build a small question/answer game, by decoupling every component in a proper Model-View-Controller manner.
First, we'll implement the model layer, with all of its components, including a model controller, which helps to implement parts of the loading logic.
Second, we'll take a look at the view layer, implemented with the help of a view controller and views. The view controller helps to organize the logic around the views on screen.
Finally, we'll tie the program together, with a controller responsible for organizing the logic between the view layer and the model layer. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access