0
-(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;
}
*終止應用程序由於未捕獲的異常 'NSRangeException',原因:' * - [NSCFArray objectAtIndex:]:索引(-4(或可能更大))超出邊界(300)」***終止應用程序由於未捕獲的異常 'NSRangeException',原因: '***
-(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];
}
肯定的。當我插入斷點。錯誤信息在這裏。
你確定'loadquestion`方法是錯誤的來源嗎? – dreamlax 2010-11-27 03:00:28
我同意夢幻,我沒有看到它發生在那裏。 – 2010-11-27 03:25:47