Lazy loading Custom UITableViewCell

this tutorial says how to lazy load or Asynchronous load custom table cell image so the scrolling of table cell is efficient.i have taken help from ¬†apple’s sample code for lazy loading or asynchronous loading and use for custom table cell.
first crate view controller and create table view as the way you want, i have created view controller and added table view.Now in view controller ,since we are requesting to url for our data ,make NSURLConnection as below

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:xmlDataUrl]];
self.connection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease];

since we have set delegate of connection to self to it will return to following method after data is loaded.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
self.connection = nil;   // release our connection
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
// create the queue to run our ParseOperation
self.queue = [[NSOperationQueue alloc] init];
ParseOperation *operation = [[ParseOperation alloc] initWithData:self.xmlData delegate:self];
[queue addOperation:operation]; // this will start the "ParseOperation"
[operation release];
self.xmlData = nil;

in delegate method create NSOperation and parse the xml in operation
After parsing is completed populate the table view.
since main work here is loading the image in table cell
dowloading the image is the same using NSURLConnection and calling appropriate method delegate method after image data is received.
the code can be downloaded from link below
LazyLoadTableImages in custom cell


sreeJanuary 11th, 2012 at 2:47 pm

i think this isw nice tutorial, how to use for json parsing.plz help me

mohanApril 19th, 2012 at 8:57 pm

same for me need for json parsing

Amit JhMay 25th, 2012 at 3:32 pm

Excellent help …..

Nhat Dinh VanJuly 10th, 2012 at 9:39 am

@sree , @mohan i ‘ve installed lazy loading with json parsing in xcode 4.3.3 and ios simulator 5.1
Hope this help you.

RandeepMarch 26th, 2013 at 3:49 pm

@Nhat Dinh Van I am trying to use your code, it is giving this error “no visible @interface for SBJsonParser declares the selector’objectWithString:error:'”.Please help.

Leave a comment

Your comment