我创建了一个有 4 个答案的测验,其中一个是正确答案。我保留在 plist 中的问题和答案。(其中有字典数组)。现在我想对一个问题有不止一个正确答案。示例:用户可以选择 ABCD 或 AC 或 BCD 等,然后按下“下一个问题”按钮。请告诉我实现使命的正确方法!
对不起我的ENG,我是俄罗斯人。
m.文件
enter code here- (void)showNextQuestion
{
if ([self.highScore integerForKey:@"HighScore"]<numCorrect){
[self.highScore setInteger:numCorrect forKey:@"HighScore"];
[self.highScore synchronize];
}
currentQuestion++; //= arc4random()%10;
if (currentQuestion <= [self.questions count]){
self.labelScore.text = [NSString stringWithFormat:@"%d", numCorrect];
self.labelHighestScore.text = [NSString stringWithFormat:@"%d", [self.highScore integerForKey:@"HighScore"]];
NSDictionary* nextQuestion = [self.questions objectAtIndex: currentQuestion];//[self.questions objectForKey:[NSString stringWithFormat:@"%d", currentQuestion]];
NSString* correctAnswer = [nextQuestion objectForKey:@"CorrectAnswer"];
self.answer = correctAnswer;
self.labelA.text = [nextQuestion objectForKey:@"A"];
self.labelB.text = [nextQuestion objectForKey:@"B"];
self.labelC.text = [nextQuestion objectForKey:@"C"];
self.labelD.text = [nextQuestion objectForKey:@"D"];
self.labelQuestion.text = [nextQuestion objectForKey:@"QuestionTitle"];
NSLog(@"%d количество вопросов", countQuestion);
int questNumber = countQuestion+1;
NSString *questNumberString = [[NSString alloc] initWithFormat:@"%d", questNumber];
NSLog(@"%@", questNumberString);
questNum.text = questNumberString;
- (IBAction)buttonPressedA:(id)sender {
//AudioServicesPlaySystemSound(SoundID1);
countQuestion++;
if([self.answer isEqualToString: @"A" ]){
numCorrect += 1;
self.labelScore.text = [NSString stringWithFormat:@"%d", numCorrect];
}
[self showNextQuestion];
}
- (IBAction)buttonPressedB:(id)sender {
// AudioServicesPlaySystemSound(SoundID1);
countQuestion++;
if([self.answer isEqualToString: @"B"]){
numCorrect += 1;
self.labelScore.text = [NSString stringWithFormat:@"%d", numCorrect];
}
[self showNextQuestion];}
- (IBAction)buttonPressedC:(id)sender {
//AudioServicesPlaySystemSound(SoundID1);
countQuestion++;
if([self.answer isEqualToString: @"C"]){
numCorrect += 1;
self.labelScore.text = [NSString stringWithFormat:@"%d", numCorrect];
}
[self showNextQuestion];}
- (IBAction)buttonPressedD:(id)sender {
//AudioServicesPlaySystemSound(SoundID1);
countQuestion++;
if([self.answer isEqualToString: @"D"]){
numCorrect += 1;
self.labelScore.text = [NSString stringWithFormat:@"%d", numCorrect];
}
[self showNextQuestion];}
@end