LBCacheImage is an image caching library for iOS
- drag the
LBCacheImage
folder to your project. - import the
CommonCrypto.h
header to the Objective C bridging header file because the NSString class extension is using CommonCrypto for hashing.
- asynchronous image download;
- cache support (memory and disk) with the option to set the days to keep the cache on disk;
- option to get the local path to an image.
- create
MD5,SHA1,SHA256
hash.
- this UIImageView class extension offers the option to set a URL string of the image location on the server;
- the image is downloaded asynchronous in the background;
- the image is saved on the disk in the caches directory;
Methods to use:
setImageWithURLString:placeholderImage:
- download and cache the imagesetImageWithURLString:placeholderImage:options:
- download and cache the imagesetImageWithURLString:placeholderImage:options:completionBlock:
- download, cache and return the imageimageForURLString:
- search the UIImage directly in cache (memory or disk), nil is returned if not found
There are 3 LBCacheImageOptions
to use:
.Default
- it first search the memory cache, if not found it search on the disk, if not found it will download asynchronous and cache it.ReloadFromWebOrCache
- it will try to reload the image from the web, if it fails it will load from local cache.LoadOnlyFromCache
- it will only search in memory and on the disk
- this class is used by the UIImageView class extension for the download but you can use it directly.
Options to use:
kDaysToKeepCache
- stores the days to keep the images in cachekDefaultHashType
- stores the hash type declared in theNSString
class extension and it has 3 values:.MD5, .SHA1, .SHA256
Methods to use:
imagePathLocationForURLString:
- a string with the local path location of the image saved on disk or nil if the image for the URLString is not founddownloadImageFromURLString:options:progressBlock:completionBlock:
- same as UIImageView class extension, cache and return the imageimageForURLString:
- same as UIImageView class extension, search the UIImage directly in cache (memory or disk), nil is returned if not found
- use this class extension to get hash value from a string.
- there are 3 options available,
MD5, SHA1 and SHA256
Methods to use:
lbHashMD5
- create an MD5 hashlbHashSHA1
- create an SHA1 hashlbHashSHA256
- create an SHA256 hashlbHashWithType:
- create a hash using the 3 available options
This content is released under the MIT License https://github.com/lucianboboc/LBCacheImage/blob/master/LICENSE.md
Enjoy!