0

異なるすべての値をsqliteに挿入し、テーブルに格納されている配列がありますが、配列にアクセスすると、すべての配列indexexに対して同じ値が表示されます。配列には4つの項目があります。

これは私がアイテムを追加している方法です

    for (int i = 0; i<[surveyQuestions count]; i++) {

      QuestionData*data=[surveyQuestions objectAtIndex:i];



      question_text=data.question_text;
      question_type=data.question_type;

      coffeeObj.question_text =question_text;
      coffeeObj.question_type=question_type;



      NSLog(@"Inserted question %@",question_text);





       [appDelegate addCoffee:coffeeObj];





      }



 - (void) addCoffee:(QuestionData *)coffeeObj {

    [coffeeObj addCoffee];

    [coffeeArray addObject:coffeeObj];

    NSLog(@"Succeessfully Added");


    }



for(int j=0;j<countmine;j++)
{
     QuestionData*data=[appDelegate.coffeeArray objectAtIndex:j];
     NSString*myTest=data.question_text;
     NSLog(myTest);
     QuestionData*dataset=[appDelegate.coffeeArray objectAtIndex:0];
     questionTextLabel.text=dataset.question_text;
}

データベースで配列を追加していますが、データベースの各インデックスの最後のエンターエンド値が常に表示されます

4

1 に答える 1

0

questionTextLabel に値を割り当てるときに、インデックス 0 を使用しました。ここでは「j」を使用する必要があります。

//In your answer its 0 here
 QuestionData*dataset=[appDelegate.coffeeArray objectAtIndex:j];     

 questionTextLabel.text=dataset.question_text;
于 2012-07-31T07:21:42.730 に答える