HMCThreadSafeMutableCollection provides thread safe array and dictionary
HMCDownloadManager provides APIs for downloading image from URL
- iOS 8.0+
- Xcode 8.3+
- Caching image on disk
- Caching image on memory
- Balancing I/O read write and memory usage
- Auto adjusting memory usage based on avaiable memory (5% of available mem in background, 80% of available mem in foreground)
- Release memory by LRU algorithm
- Auto remove unsued cache files on disk after 30 days
- Get image from url with target size
- Set UIImageView with image from URL
- Set UIButton with image from URL
HMCImageCache is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'HMCImageCache'
To get image caching instance:
HMCImageCache *imageCache = [HMCImageCache sharedInstance];
UIImage *image = ...;
NSString *identifier = ...;
[imageCache storeImage:image withKey:identifier];
image = [imageCache imageFromKey:identifier storeToMem:YES]; // storeToMem: do you want image store to memory
CGSize size = CGSizeMake(300,400); // Image with size 300px x 400 px
image = [imageCache imageFromKey:identifier withSize:size];
[imageCache imageFromURL:url
withTargetSize:CGSizeMake(300,400)
completion:^(UIImage *image){
// do something with image
}
callbackQueue:dispatch_get_main_queue()];
NSURL *url;
UIImageView *imageView;
[imageView HMCSetImageFromURL:url forState: UIControlStateNormal];
NSURL *url;
UIButton *button;
[button HMCSetImageFromURL:url forState: UIControlStateNormal];
[imageCache removeImageForKey:identifier];
[imageCache removeAllCache];
chuonghuynh, minhchuong.itus@gmail.com
HMCImageCache is available under the MIT license. See the LICENSE file for more info.