-(void)loadquestion {
NSBundle *bundle = [NSBundle mainBundle];
NSString *textfilePath = [bundle pathForResource:@"MathPSLE" ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:textfilePath encoding:NSUTF8StringEncoding error:nil];
NSArray *quizArray = [[NSArray alloc] initWithArray:[fileContents componentsSeparatedByString:@"\n"]];
theQuiz = quizArray;
}
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (-4( or possibly larger)) beyond bounds (300)'
-(void)askquestion {
QuestionNumber = QuestionNumber +1;
NSInteger row = 0;
if (QuestionNumber == 1) {
row = QuestionNumber -1;
}
else {
row = ((QuestionNumber -1 *6));
}
NSString *selected = [theQuiz objectAtIndex:row];
NSString *activeQuestion = [[NSString alloc] initWithFormat:@"Question: %@",selected];
[ansButton1 setTitle:[theQuiz objectAtIndex:row+1] forState: UIControlStateNormal];
[ansButton2 setTitle:[theQuiz objectAtIndex:row+2] forState: UIControlStateNormal];
[ansButton3 setTitle:[theQuiz objectAtIndex:row+3] forState: UIControlStateNormal];
[ansButton4 setTitle:[theQuiz objectAtIndex:row+4] forState: UIControlStateNormal];
rightAnswer = [[theQuiz objectAtIndex:row+5]intValue];
questionLabel.text = activeQuestion;
[selected release];
[activeQuestion release];
}
-(IBAction)next_Button {
[self askquestion];
}
yes. when i insert the breakpoint. the error message is here.
loadquestion
method is where the error is from? – dreamlax