views:

188

answers:

1

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;
        }

    }

}
+1  A: 

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

Kirk van Gorkom
LazyTableImages didn't help me. I'm using a different approach for lazy loading. Thank you for your answer though.
looneygrc
I got it working using indexPathsForVisibleRows,finally. Thank you mate.
looneygrc