LBCache is an image caching library for iOS
- drag the
LBCachefolder to your project. - import
Securityframework andlibobjc.dyliblibrary from Xcode. - import the
"UIImageView+LBcategory.h" - optional, if needed (import
LBCache.h, NSURLConnection+LBcategory, NSString+LBcategory, NSData+LBcategory).
- 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.
- upload,download JSON data from the web.
- create MD5,SHA1,SHA256 hash and hmac.
- encrypt/decrypt nstring/data.
- create an initialization vector.
- encode/decode base64.
- this UIImageView category offer the option to set a URL string of the image location on the server;
- the image is downloaded asynchrnous in the background;
- the image is saved on the disk in the caches directory;
Methods to use:
setImageURLString:placeholderImage:- download and cache the imagesetImageURLString:placeholderImage:options:- download and cache the imagesetImageURLString: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 options to use:
LBCacheImageOptionsDefault- it first search the memory cache, if not found it search on the disk, if not found it will download asynchronous and cache itLBCacheImageOptionsLoadOnlyFromWebIgnoreCache- it will ignore the cache and download every time from the webLBCacheImageOptionsLoadOnlyFromCache- it will only search in memory and on the disk
- this class is used by the UIImageView category 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+LBcategory.hcategory and it has 3 values:HashTypeMD5, HashTypeSHA1, HashTypeSHA256
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:completionBlock:- same as UIImageView+Lbcategory, cache and return the imageimageForURLString:- same as UIImageView+LBcategory, search the UIImage directly in cache (memory or disk), nil is returned if not found
- this class is used by the LBCache to download the UIImage/NSData from a URL but it can also be used to work with a web API.
- an error domain was created for this class category, check NSURLConnection+LBcategory.h for more details.
Methods to use:
downloadImageFromURLString:completionBlock:- download an image from the webdownloadJSONObjectFromURLString:urlData:method:completionBlock:- this method can be used for GET requests (pass nil for urlData parameter) or POST requests (pass the urlData string to be set as HTTPBody)downloadJSONObjectFromURLString:objectForURLData:method:completionBlock:- this method can be used for GET requests (pass nil for objectForURLData parameter) or POST requests (pass the objectForURLData object (array or dictionary which is serialized into a JSON and set as HTTPBody)
- use this class category to get hash value from a string or to encrypt/decrypt data.
- 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 optionslbHashMacWithKey:- create a hash Message Authentication Code using a KeyencryptedWithAESUsingKey:andIV:- encrypt data using a Key and IVdecryptedWithAESUsingKey:andIV:- decrypt data using a Key and IV
- use this category to encrypt/decrypt data, create initialization vector for ecryption and encode in base64
Methods to use:
base64Encoding- encode base64dataWithBase64EncodedString:- decode base64 stringinitializationVectorOfLength:- get initialization vector, random generated bytes using SecRandomCopyBytesdefaultInitializationVector- get initialization vector, random generated bytes using SecRandomCopyBytesencryptedWithAESUsingKey:andIV:- encrypt data using a Key and IVdecryptedWithAESUsingKey:andIV:- decrypt data using a Key and IV
Enjoy!