Home

Awesome

LBCache

Version License Platform

LBCache is an asynchronous image cache framework for iOS

How to use

UIImageView+LBCategory.h

There are 3 options to use:


  __weak UIImageView *weakImgView = cell.imgView;    
  [cell.imgView setImageWithURLString: self.array[indexPath.row] placeholderImage: nil options: LBCacheImageOptionsDefault progressBlock:^(NSUInteger percent) {
      NSLog(@"percent: %ld",percent);
  } completionBlock:^(UIImage * image, NSError * error) {
      dispatch_async(dispatch_get_main_queue(), ^{
          weakImgView.image = image;
      });
  }];

LBCacheManager.h

This class is used by the UIImageView category for the download but you can use it directly. You can use methods from LBCacheManager to get the UIImage object from the disk or the path location where the image is cached.


  __weak UIImageView *weakImgView = self.imgView;
  [[LBCacheManager sharedInstance] downloadImageFromURLString: self.array[indexPath.row] options: LBCacheImageOptionsDefault progressBlock:^(NSUInteger percent) {
      NSLog(@"percent: %ld",percent);
  } completionBlock:^(UIImage * image, NSError * error) {
      dispatch_async(dispatch_get_main_queue(), ^{
          weakImgView.image = image;
      });
  }];
  
  // you can also get the image from the disk using the urlString.
  UIImage *image = [[LBCacheManager sharedInstance] imageForURLString: urlString];

  // you can get the image path where it is cached.
  NSString *imgPath = [[LBCacheManager sharedInstance] imagePathLocationForURLString:urlString];

NSString+LBCategory.h

You can use this class category to get hash value from a string.

Methods to use:


  // you can use lbHashMD5, lbHashSHA1 or lbHashSHA256 method to get the specific hash from a string.
  NSString *hashStr = [urlString lbHashSHA1];
  
  // you can also use the lbHashWithType method and pass an option HashTypeMD5, HashTypeSHA1 or HashTypeSHA256
  NSString *hashStr = [urlString lbHashWithType: HashTypeMD5];

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods

To integrate LBCache into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'LBCache'

Then, run the following command:

$ pod install

LICENSE

This content is released under the MIT License https://github.com/lucianboboc/LBCache/blob/master/LICENSE.md

Enjoy!