テーブルビュー名「tableAll」、配列「thumbVideoListArray」(最初にこの配列は空です)があり、画像のURLを持つ配列「objDelegate.listVidArray」があります..ミスチェックがあると思います。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if([thumbVideoListArray count] == 0)
{
[NSThread detachNewThreadSelector:@selector(fetchImage:) toTarget:self withObject:indexPath];
}
else
{
UIImage *img1 = [thumbVideoListArray objectAtIndex:indexPath.row];
if(img1)
{
cell.thumbImage = [thumbVideoListArray objectAtIndex:indexPath.row];
}
else
{
[NSThread detachNewThreadSelector:@selector(fetchImage:) toTarget:self withObject:indexPath];
}
}
}
- (void)fetchImage:(NSIndexPath *)indexPath
{
NSLog(@"in thead");
if([[[[objDelegate.listVidArray objectAtIndex:[objDelegate.listVidArray count]-(indexPath.section+1)]valueForKey:@"videoList"]valueForKey:@"media_id"]objectAtIndex:indexPath.row])
{
NSData *dataImage = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[[[[objDelegate.listVidArray objectAtIndex:[objDelegate.listVidArray count]-(indexPath.section+1)]valueForKey:@"videoList"]valueForKey:@"img"]objectAtIndex:indexPath.row]]]];
if([dataImage length])
{
UIImage *imageThumb = [UIImage imageWithData:dataImage];
[thumbVideoListArray addObject:imageThumb];
// Reload rows with the fetched image in other thread
[self performSelectorOnMainThread:@selector(reloadTable:) withObject:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]] waitUntilDone:NO];
}
}
}
- (void)reloadTable:(NSArray *)array
{
[tableAll reloadRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationNone];
}