Graphics Programs Reference
In-Depth Information
Declarations
To manage its relationships and responsibilities, the QuizViewController object
needs five instance variables and two methods. In this section, you will declare these in the
QuizViewController header file, QuizViewController.h .
Declaring instance variables
Here are the five instance variables QuizViewController needs:
questions
a pointer to an NSMutableArray containing instances of NSString
answers
a pointer to another NSMutableArray containing instances of NSString
currentQuestionIndex
an int that holds the index of the current question in the questions array
questionField
a pointer to the UILabel object where the current question will be displayed
answerField
a pointer to the UILabel object where the current answer will be displayed
In the project navigator, select QuizViewController.h to open the file in the editor.
Add the following code: a set of curly brackets and, inside the brackets, the declarations for
the five instance variables. Notice the bold type? In this topic, code that you need to add is
always bold; the code that's not bold is there to tell you where to type in the new stuff.
@interface QuizViewController : UIViewController
{
int currentQuestionIndex;
Search WWH ::




Custom Search