Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Solution approach for the local file caching of the images. #5

Closed
jberlana opened this Issue · 1 comment

2 participants

Javier Berlana Matthijs Hollemans
Javier Berlana

As you commented on your code, there is a problem with the file caching mechanism because at the initialization of the table when the image is already in the file cache it will be loaded synchronously and we will get it immediately from -addLazyImageForCell:withIndexPath:. and at that point the cell has not been hooked up to an index-path yet, and so the image won't be displayed.

I solve this problem looking in the filesystem for the image if it's not found in the memory cache, probably is not the best solution but it do the work. Hope it help.

- (UIImage*)cachedImageWithURL:(NSURL*)url
{
    NSString *key = [self keyForURL:url];;
    UIImage *img  = [self.images objectForKey:key];

    if (img == nil) 
    {
        NSString *path = [self.cacheDirectory stringByAppendingPathComponent:key];
        img = [UIImage imageWithContentsOfFile:path];

        if (img != nil)
            [self.images setObject:img forKey:key];
    }

    return img;
}

Regards.

Matthijs Hollemans
Owner

Closing this because the code is now deprecated.

Matthijs Hollemans hollance closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.