I want to read one data array in iOS, but I read only one record in this array, I checked the array and it contains 10 items.
for(NSString *po in list) {
infor.poster = [po valueForKey:@"Poster"];
infor.vName= [po valueForKey:@"VName"];
infor.name = [po valueForKey:@"Name"];
infor.HDtrailerPath = [po valueForKey:@"HDTrailerPath"];
[arrfilm addObject:infor];
}
dispatch_async(dispatch_get_main_queue(), ^{
int widthlblscroll = 0;
for (Inforfilm *u in arrfilm) {
Inforfilm *infoF = [[Inforfilm alloc]init];
infoF.poster = [u valueForKey:@"poster"];
infoF.name = [u valueForKey:@"name"];
NSLog(@"%@",infoF.poster);
NSLog(@"%@",infoF.name);
}
});
You were adding the very same instance of
Inforfilmmultiple times to your array. Just because you update its properties does not mean it is a new instance. To prevent this, instanciate a new instance on every loop iteration. as done in the inner first line.