SDWebImage docs says it caches automatically. As for scaling, there's plenty of net code like this around. The trick is integrating it with SDWebImage. Fortunately, it provides a completion block:
NSURL *url = /* prepare a url... see note below */
[myCell.homeImage setImageWithURL:url
placeholderImage:[UIImage imageNamed:@"menuButton.png"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
// inspect cacheType here to make sure it's cached as you want it
myCell.homeImage.image = [self scaleImage:image toSize:CGSizeMake(75,75)];
}];
A simple scale would look something like this (not tested):
- (UIImage *)scale:(UIImage *)image toSize:(CGSize)size {
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Incidentally, I notice that you use generic string manipulation to build the URL. You'd be better off using the specialized methods on string as follows:
// this can be defined outside cellForRowAtIndexPath
NSURL *baseUrl = [NSURL urlWithString:@"http://example.com/"];
NSString *imageItemName = [homeImages objectAtIndex:row];
NSURL *url = [NSURL URLWithString:imageItemName relativeToURL:baseURL];