0
__block UIActivityIndicatorView *activityIndicator;
__weak UIImageView *weakImageView = self.headpic;
[self.headpic setImageWithURL:imageUrl placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize){
if (!activityIndicator) {
    [weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]];
    activityIndicator.center = weakImageView.center;
    [activityIndicator startAnimating];
  }
}
                  completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType){
                      [activityIndicator removeFromSuperview];
                      activityIndicator = nil;
                  }];

this code can set headpic's image, and I want to download the server image(from imageUrl) to NSHomeDirectory at the same time, how to do?

yegomo
  • 297
  • 2
  • 11

1 Answers1

0

Look at EGOCache for store images locally. https://github.com/enormego/EGOCache You can use default EGOCache directory (inside NSCachesDirectory) or initialize it with your own directory.

Usage is very simple:

[[EGOCache globalCache] setImage:image forKey:@"your_key"];
m8labs
  • 3,671
  • 2
  • 30
  • 32