views:

51

answers:

3

Hi, I am creating a multilayered iPhone app using a navigation controller and the app includes a lot of images in every layer. I was wondering if it is a good idea to use a SQLite database to store all the images and extract them to the page when needed or should i just add all the images to the resources folder and pull them into the app as needed? I have used a SQLite database in an app before but the app was still slightly slow. Is there something else that I can do besides this to improve the speed of the app? I'm all ears, any help is appreciated. Thanks in advance.

+1  A: 

I don't think you would get a faster response from SQLite than the file system. Either way it is stored in a file. I'm afraid that is the fastest you can do. That being said, you can make sure to load some files and views before they are needed if you have enough memory to do so. You can do this asynchronously while another part of the application is running using NSObject's performSelectorInBackground method. Also, you can reduce both load and processing times by optimizing the images' width and height beforehand for their target use. This makes a huge difference in both load and presentation time when you have a lot of images.

Peter DeWeese
+2  A: 

If your images never change, there are some advantages you will gain from [UIImage imageNamed:], which is data caching. In your case, resource loading should also be faster than database access, because you access the resource directly instead of going through the database access layer. Caching also benefits you that you do not have to manage data caching by yourself, but you might have to release it from UIImageView when it is not visible to allow the library to do cache purging when needed.

tia
A: 

One thing to check is how long is it taking to query the database?

Check how long it takes from the query start until the results are returned. If this is slow, make sure you have indexed the column that you are using in your "where" statement.

You can quickly check with this awesome SQLite GUI http://menial.co.uk/software/base/ and or add these.

I would get the data from the filesystem.

John Ballinger