1

Um using AsyncImageView class here. In the documentation they are saying that "By default, all loaded images are cached". You can see it at the last paragraph in the documentation.

But the problem is when I try to load the images again it comes with the placeholder and wait a few seconds to load the image from URL again even it has been loaded successfully last time.

That means it wasn't cached, right ?
So um asking if there a problem with my code ?
Why the images not been cached like using the SDWebImage ?

These is my code :

AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:CGRectMake(0, 0, productCellWidth, productCellHeight)];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
NSURL *URL =  [NSURL URLWithString:[NSString stringWithFormat:ProductPicture]];
[AsyncImageLoader defaultCache];
[[AsyncImageLoader sharedLoader]loadImageWithURL:URL target:self success:@selector(successSelector) failure:@selector(failureSelector)];
j0k
  • 22,600
  • 28
  • 79
  • 90
Atef
  • 2,872
  • 1
  • 36
  • 32
  • "the cache will keep building up until a memory warning is triggered". Have you triggered a memory warning? – sunkehappy Nov 24 '12 at 10:05

4 Answers4

1

there is another library I used it before and it working well this library called "SDWebImage" you can use it simply by a method:

[imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
               placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

and it cache images automatically and it support loading only from cache (if you need).

MhammedMohie
  • 312
  • 2
  • 9
  • Ok Um using it right now and it working great but how to tell it the time to cache, meaning If I want to clear the cache ? I want to cache new images each 4 days, So I want it to call the server each 4 days, how to set these property ? – Atef Nov 24 '12 at 12:35
1

in SDImageCache.m you will find this line of code:

static NSInteger cacheMaxCacheAge = 60*60*24*7; // 1 week

it's the cached image lifetime you can change it to 4 days instead of 7 days

MhammedMohie
  • 312
  • 2
  • 9
0

to me your code looks wrong. you just set imageURL of the AsyncImageView.

You dont deal with the loader

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
-2

I've solved this problem: you need to add

#import "AsyncImageView.h"

in your file .m

and USE

NSURL *url = [NSURL URLWithString:yourUrlString];
photo.imageURL = url; 

OR FOR EXAMPLE

cell.imageView.imageURL = url;

and NOT

UIImage *theImage = [UIImage imageWithData:imageData];
photo.image = theImage;
Francesco
  • 1,128
  • 12
  • 22