nicklockwood / AsyncImageView

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#asyncimageview
Other
906 stars 186 forks source link

When using AsyncImageLoader's LoadImageWithURL methods, the method simply returns #27

Open cnohara opened 11 years ago

cnohara commented 11 years ago

Unless I'm mistaken, upon first usage of a line such as: [[AsyncImageLoader sharedLoader] loadImageWithURL: someURLHere], it works the first time and AsyncImageLoadDidFinish or AsyncImageLoadDidFail are posted. However, when trying a second time, if the image is already in the cache, then the method returns without posting any notifications.

I did a quick fix by adding following notification post after the success check:

- (void)loadImageWithURL:(NSURL *)URL target:(id)target success:(SEL)success     failure:(SEL)failure
{
    //check cache
    UIImage *image = [_cache objectForKey:URL];
    if (image)
    {
        [self cancelLoadingImagesForTarget:self action:success];
        if (success)
            [target performSelectorOnMainThread:success withObject:image waitUntilDone:NO];

        [[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish
                                                        object:nil
                                                      userInfo:    [NSDictionary dictionaryWithObjectsAndKeys:image, @"image", nil]];

    return;
}

....

}

This seems to do the trick for me and was wondering if this is an issue or am I misunderstanding the AsyncImageLoader usage. Thanks.