views:

76

answers:

3

I want to fetch images into my application cache in a faster way.

I do a map kinda app by loading at about 25 images at a time in a UIscrollView in which each image takes about 1 second for downloading.

All images are of size 64KB and 256*256 dimensions. I am doing caching, So after the first time when i scroll there will be around 7-8 images to load and that too takes each second each. So in the middle of scrolling the map it stops for around 7-8 seconds.

Is there a way that I can increase the speed of getting images, so that I will be able to load atleast 4-6 images a second?

+3  A: 

You need to free the main thread and do this on a background thread. When you're doing heavy work on the main thread, it will block and you app will appear unresponsive. (If you don't know on what thread you're running, your are probably on the main thread.)

Take a look at the apple concurrency guide.

gcamp
So for the above reasons, u would have understud now that when we do a tiled map its of no use doing the threading.
wolverine
A: 

Your web browser does this by spinning up a number of background fetch threads in parallel (reducing the overall download time) and displaying the map tiles as they come in (giving the illusion of higher responsiveness).

You can get a better feel for this by installing Firebug on Firefox, and then activate it while loading a complex page. It'll show you a graph over time of how long it takes each page component to be fetched, and this shows the parallelism.

Jim Ferrans
+3  A: 

You should use CATiledLayer, which spins off a separate thread for rendering each tile. It's how the Maps app does its drawing. You can have it download the images within the drawing code, and it won't block the main thread, so scrolling will be smooth. It'll still take time to download the images, but if you have a low-resolution proxy image you can show that while it loads the real image.

lucius