Iphone – How to save a UIImage to the application’s Bundle

cachingiphoneuiimageuikit

I am currently getting images from the 'Documents' directory (using -imageWithContentsOfFile:) with no problems except that I cannot get the images to display immediately (for example as soon as touchesEnded was called). I am assuming that this has to do with image caching and that image objects created in the above way are not cached? So, I figure, I will cache the image object after creating it and then use the cached image using -imageNamed:. So how can I save a UIImage object to the application's Bundle and/or Cache it?

Best Answer

You can't modify the application bundle once it's on the iPhone. The entire thing is code signed, and changing it would cause it to not run any more.

Why don't you pre-load the images you need at startup? Be careful, though, as large images take up a lot of memory, and the kernel could kill your app if it goes overboard.