Quiz app


Im having an issue. I can click the aster button and it displays an answer 14 no others. When I click the question button it does nothing. I have the labels set correctly or at least they are set the same (questionField and answerField). the buttons same (showAnswer and showQuestion)

any ideas on what I have done wrong.

@interface QuizViewController : UIViewController

int currentQuestionIndex;

//the model objects
NSMutableArray *questions;
NSMutableArray *answers;

//the view objects - dont worry about IBOutlet

//Well talk about it shortly

IBOutlet UILabel *questionField;
IBOutlet UILabel *answerField;





-(id)initWithNibName:(NSString *)nibNameOrNil

bundle:(NSBundle *)nibBundleOrNil

//call the intit method implemented by the superclass

self = [super initWithNibName:nibNameOrNil

if (self) {
    //create two arrays and make the pointers point to them
    questions=[[NSMutableArray alloc] init];
    answers=[[NSMutableArray alloc] init];
    //adding questions and answers to the arrays
    [questions addObject:@"what is 7+7?" ];
    [answers addObject:@"14"];
    [questions addObject:@"what is the capitol of Vermont?" ];
    [answers addObject:@"Montpelier"];
    [questions addObject:@"From what is cognac made?" ];
    [answers addObject:@"Grapes"];
        //return the address of the new object
return self;


//step to the next question

//am I past the last question?

if (currentQuestionIndex == [questions count]){

    //go back to the first question
    currentQuestionIndex = 0;


//get the string at that index in the questions array
NSString *question=[questions objectAtIndex:-currentQuestionIndex];

//log the string to the console
NSLog(@"displaying question: %@", question);

//clear the answer field
[answerField setText:@"???"];


//What is the current question
NSString *answer = [answers objectAtIndex:currentQuestionIndex];

//display it in the answer field
[answerField setText:answer];




remove the - in front of currentQuestionIndex in showQuestion:'s [questions objectAtIndex:-currentQuestionIndex]


Thank you