The Big Three: Models, Views, Controllers
Cocoa Touch gives you hundreds of object classes to wrap your head around. Fortunately, most of these classes fall into three categories. And the objects in these categories interact in a simple and well-defined way.
Every iPhone application uses a simple Model-View-Controller design pattern. And since developers are just as lazy with writing as they are with coding, you'll often find this referred to as "MVC."
Note
If you've used other languages and development environments, you'll be very happy to know that MVC in Cocoa is no different than the ones you're used to. The objects change, but the concepts don't.
To see the simplicity of this design, take a look at Figure 3-1.
Figure 3-1. This graphic shows how models, views, and controllers work together, as described on the following pages.
That's all there is to an iPhone app. And things get even better when you realize that views and controllers in the frameworks already do most of the hard work. Even the creation of model objects is simplified with the help of Cocoa Touch.
So what are the roles of each of these object types? Read on.
Views
You know all those buttons, scrolling lists, web browsers, and everything else that appears on your iPhone screen? Those are all views. Views know how to present your application's data. Some views also know how to react to user input. A UIButton view responds ...
Get iPhone App Development: The Missing Manual 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.