views:

1370

answers:

3

Hi

I am developing iPhone application and In that application I've one TableViewController, and that TableViewController made up of Custom table cell. into those cell I am loading image from URL, but the scrolling is not that smooth,(because each cell load images everytime when scrolling happen.)

So I decided to store those images into application document folder, but i don't how to use document folder in iPhone when application is in running state.

any suggestion?

And on other forums I found that SQLITE has blob datatype to store binary data,

which method is efficient, document folder or sqlite to store image?

thanks in advance.

A: 

You could use NSFileManager's createFileAtPath to save any NSData into a file.

To get the Documents directory, use this:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
leonho
+1  A: 

Storing the images on the device may improve things somewhat, but it will not make scrolling really smooth. The reason scrolling tends to become choppy is that a synchronous function in your cell code means that you are blocking the run loop, which prevents animation. If you want to speed up scrolling you need to get rid of the blocking event, by making it asynchronous (though this still may result it chunky scrolling if you're asynch callbacks take a lot of CPU time), or moving the blocking code off the main thread.

If you move your loads off the main thread then either individual files or an sqlite3 database will work fine. The other big issue you will find is that cells are not updated while scrolling. That means if you perform an asynch image load in responds to the cell loading the image will not appear in the cell until the user is done scrolling, which is generally not the desired experience. In order to do avoid that you need to predictively load the images into ram before the user scrolls over them.

Louis Gerbarg
A: 

code snippet will greatly appreciated.as I am new to objective c and cocoa.

thanks

Amit Vaghela