Graphics Programs Reference
In-Depth Information
Figure 1.15 Setting answerField
Notice that you drag
from
the object with the pointer
to
the object that you want that
pointer to point at. Also, notice that the pointers that appear in the connections panel are
the ones that you decorated with
IBOutlet
in
QuizViewController.h
.
Setting targets and actions
When a
UIButton
is tapped, it sends a message to another object. The object that is sent
the message is called the
target
. The message is called the
action
, and it is the name of the
method that tapping the button should trigger. So the button needs answers to two ques-
tions: “Who's the target?” and “What's the action?” For the
Show Question
button, we
want the target to be
QuizViewController
and the action to be
showQuestion:
.
To set an object's target and action, you Control-drag
from
the object
to
its target. When
you release the mouse, the target is set, and a pop-up menu appears that lets you choose