0

I'm using ASIHTTPRequest to pull the JSON data from WCF. I then looping through the data and fetching image from a URL to display UITableView. This practice is extremely slow on 3G network. Is there anything that I can do to make it faster!

Here is a sample code

This pice of code will grab image from the URL. This is under tableView cellFroRowAtIndexPath:

// Add image
NSString* trimmedCode = [[courseList objectAtIndex:indexPath.row] stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *imageName = [NSString stringWithFormat:@"http://www.someURL.com/images/%@.png", trimmedCode];
NSURL *url = [NSURL URLWithString: imageName];
cell.myImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];

return cell;

Any help?

HardCode
  • 2,025
  • 4
  • 33
  • 55

3 Answers3

0

3G is slow on response times. It is designed to send files reasonably quickly once it has started. But each http request incurrs significant latency.

This is why you don't see real-time action multiplayer games over 3G.

Almo
  • 15,538
  • 13
  • 67
  • 95
  • So, is there any way to background cache the data (image) before hand? – HardCode Nov 10 '11 at 16:05
  • Maybe you could pack the images in some kind of archive on the server so that you only do one http request to get them all. Or you could write a seperate thread to do your loop to get the images asynchronously. – Almo Nov 10 '11 at 16:08
0

A great library that I use is EGOPhotoViewer. You can asynchronously load images and it automatically caches the images for you so you don't need to download them again. The best part is that you can have a placeholder image shown until your desired image is downloaded.

You can find the library here: https://github.com/enormego/PhotoViewer

Note: I have no affiliation with the creation or the creators of this library. It's just an awesome one based off of the three20 project.

nicholjs
  • 1,762
  • 18
  • 30
0

I found a similar question on Stackoverflow, which address my answer. More specific answer to my question is, I'm using the SDWebImage library. Which is much simpler to use! Thank you for all of your support.

Community
  • 1
  • 1
HardCode
  • 2,025
  • 4
  • 33
  • 55