Skip to content

Latest commit

 

History

History
62 lines (36 loc) · 1.77 KB

File metadata and controls

62 lines (36 loc) · 1.77 KB

This is a simple library that can address most of the requirement of asynchronously dowloading, caching and managing network image resources.

Loading an image is straightforward:

-(UIImage *) loadImage:(HTTPImageRequest *)request;

Interface

To load an image, one will have to instantiate an HTTPImageRequest object, then use HTTPImageManager to issue the request. HTTPImageRequest has the following variations:

  • Set a target UIView for displaying the loaded image
+(id) requestWithURL:(NSString *)url forUIView: (UIView *)v;

when the 'v' is a UIImageView, its 'image' property will be set to the loaded image;
when the 'v' is a UIButton, [((UIButton *)v) setImage:image forState:UIControlStateNormal]; is called;
when the 'v' is of any other type, nothing is set.

  • Or use this more generic form, to be free to deal with the loaded image in the HTTPImageCompletionBlock.
+(id) requestWithURL:(NSString *)url forUIView: (UIView *)v completionBlock: (HTTPImageCompletionBlock)block;
  • Or set a delegate for being notified of the result
+(id) requestWithURL:(NSString *)url andDelegate:(id)delegate;

Three-Level Caching Hierarchy

[memory cache] -> [persistent storage cache] -> [network loader]

The memory cache is optional. To use too much memory cache may kill the system resource very fast. It is important to do so with a list view, though.

FIFO and LIFO Operation Queue

LIFO is to improve responsiveness of a tableview, for example, when a user scrolls a list that loads a quite number of images sequentially.

Work with reused cells in UITableView

When used in UITableViews that utilize techniques of reusing cell views,

Progressive downloading