I have array in which i insert all the values in sqlite which are different and are stored in the table but when i access the array it shows the same values for all the array indexex i have four items in the array
This how i am adding the items
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;
}
In data base i am adding the array but it always showing the last enterend values in each index in the data base
You have used index 0 while assigning the value to questionTextLabel. You should have use “j” here.