Graphics Programs Reference
In-Depth Information
custom classes, which typically have names that sound like data-bearing objects, such as
InsurancePolicy or PlayerHistory .
View and model objects are the factory workers of an application - they focus tightly on
specific tasks. For example, an instance of UILabel (a view object) knows how to dis-
play text in a given font within a given rectangle. An NSString instance (a model ob-
ject) knows how to store a character string. But the label doesn't know what text it should
display, and the string doesn't know what characters it should store.
This is where controller objects come in. Controllers are the managers in an application.
They keep the view and model objects in sync, control the “flow” of the application, and
save the model objects out to the filesystem ( Figure 1.11 ). Controllers are the least reus-
able classes that you will write, and they tend to have names like ScheduleControl-
ler and ScoreViewController .
Figure 1.11 MVC pattern
When you create a new iOS project from a template, the template automatically makes a
controller object for you. For Quiz , this controller is the QuizViewController . Most
applications have more than one controller object, but a simple application like Quiz only
needs one. (Actually, the template creates another controller for Quiz - the QuizAp-
pDelegate . Every iOS application has an “app delegate” object, and it is the primary
controller of the application. However, to keep things simple, we won't use the app deleg-
ate until Chapter 6 . )
 
Search WWH ::




Custom Search