Graphics Programs Reference
In-Depth Information
Model-View-Controller
You may hear iOS programmers mention the Model-View-Controller pattern. What this
means is every object you create is exactly one of the following: a model object, a view ob-
ject, or a controller object.
View objects
are visible to the user. In
Quiz
, the buttons, labels, and the view they are
placed on top of are all view objects. Views are usually standard
UIView
subclasses
(
UIButton
,
UISlider
), but you will sometimes write custom view classes. These typ-
ically have names like
DangerMeterView
or
IncomeGraphView
.
Model objects
hold data and know nothing about the user interface. In this application, the
model objects will be two lists of strings: the
questions
array and the
answers
array.
Figure 1.10
displays the object diagram of the
Quiz
application's model objects.
Figure 1.10 Diagram of model objects in Quiz
Model objects typically use standard collection classes (
NSArray
,
NSDictionary
,
NSSet
) and standard value types (
NSString
,
NSDate
,
NSNumber
). But there can be