0

4 つの答えがあるクイズを作成しましたが、そのうちの 1 つが正解です。質問と回答は plist に保存します (辞書の配列がある場所)。今、私は1つの質問に対して複数の正しい答えを持ちたいと思っています. 例: ユーザーは ABCD または AC または BCD などを選択し、「次の質問」ボタンを押すことができます。私の使命を実現する正しい方法を教えてください!

英語で申し訳ありませんが、私はロシア人です。

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
4

1 に答える 1