I have X sections. I want to “lazy” load images in different Custom Cell for each section. Is there any better way to do that than checking each time if cellArray.object (visibleCells) is equal to Ccell in which i want to load those images?
UPDATE: Here is a working code(for now …). My code is based on Adrian Kosmaczewski’s example here.
- (void)loadContentForVisibleCellsInSection{
NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
for (NSIndexPath *indexPath in visiblePaths)
{
switch (indexPath.section) {
case 0:{
CustomCell *cell = (CustomCell *)[self.tableView cellForRowAtIndexPath:indexPath];
[cell loadImage];
}
break;
default:
break;
}
}
}
Rather than enumerating all your cells to test for visibility, use
[tableView indexPathsForVisibleRows]to get the list of visible cells from the tableview itself. For more lazy loading advice, look at this sample code from Apple: LazyTableImages