Graphics Programs Reference
In-Depth Information
// The model objects
NSMutableArray *questions;
NSMutableArray *answers;
// The view objects - don't worry about IBOutlet -
// we'll talk about it shortly
IBOutlet UILabel *questionField;
IBOutlet UILabel *answerField;
}
@end
(Scary syntax? Feelings of dismay? Don't panic - you will learn more about the
Objective-C language in the next chapter. For now, just keep going.)
Declaring methods
Each of the buttons needs to trigger a method in the QuizViewController . A method
is a lot like a function - a list of instructions to be executed. Declare two methods in
QuizViewController.h . Add this code after the curly brackets and before the
@end .
@interface QuizViewController : UIViewController
{
int currentQuestionIndex;
// The model objects
NSMutableArray *questions;
NSMutableArray *answers;
// The view objects
IBOutlet UILabel *questionField;
IBOutlet UILabel *answerField;
}
- (IBAction)showQuestion:(id)sender;
- (IBAction)showAnswer:(id)sender;
@end
Save QuizViewController.h .
What do IBOutlet and IBAction do in the declarations you just entered? They allow
you to connect your controller and your view objects in the XIB file.
Search WWH ::




Custom Search