Skip to content

pritasam/LBCache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

LBCache

LBCache is an image caching library for iOS

How to use this library:

  • drag the LBCache folder to your project.
  • import Security framework and libobjc.dylib library from Xcode.
  • import the "UIImageView+LBcategory.h"
  • optional, if needed (import LBCache.h, NSURLConnection+LBcategory, NSString+LBcategory, NSData+LBcategory).

This library offer:

  • 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.

Classes to use:

I. UIImageView+LBcategory:

  • 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 image
  • setImageURLString:placeholderImage:options: - download and cache the image
  • setImageURLString:placeholderImage:options:completionBlock: - download, cache and return the image
  • imageForURLString: - 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 it
  • LBCacheImageOptionsLoadOnlyFromWebIgnoreCache - it will ignore the cache and download every time from the web
  • LBCacheImageOptionsLoadOnlyFromCache - it will only search in memory and on the disk

II. LBCache:

  • 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 cache
  • kDefaultHashType - stores the hash type declared in the NSString+LBcategory.h category 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 found
  • downloadImageFromURLString:options:completionBlock: - same as UIImageView+Lbcategory, cache and return the image
  • imageForURLString: - same as UIImageView+LBcategory, search the UIImage directly in cache (memory or disk), nil is returned if not found

III. NSURLConnection+LBcategory:

  • 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 web
  • downloadJSONObjectFromURLString: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)

III. NSString+LBcategory:

  • 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 hash
  • lbHashSHA1 - create an SHA1 hash
  • lbHashSHA256 - create an SHA256 hash
  • lbHashWithType: - create a hash using the 3 available options
  • lbHashMacWithKey: - create a hash Message Authentication Code using a Key
  • encryptedWithAESUsingKey:andIV: - encrypt data using a Key and IV
  • decryptedWithAESUsingKey:andIV: - decrypt data using a Key and IV

III. NSData+LBcategory:

  • use this category to encrypt/decrypt data, create initialization vector for ecryption and encode in base64

Methods to use:

  • base64Encoding - encode base64
  • dataWithBase64EncodedString: - decode base64 string
  • initializationVectorOfLength: - get initialization vector, random generated bytes using SecRandomCopyBytes
  • defaultInitializationVector - get initialization vector, random generated bytes using SecRandomCopyBytes
  • encryptedWithAESUsingKey:andIV: - encrypt data using a Key and IV
  • decryptedWithAESUsingKey:andIV: - decrypt data using a Key and IV

Enjoy!

About

Image cache library for iOS, including classes for web services and encryption.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published