views:

469

answers:

1

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?

+4  A: 

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.

Shaggy Frog
Thanks. Hmmm...Would there be any other reason you could think of for UIImages created using -imageWithContentsOfFile: not being displayed while UIImages created using -imageNamed: are displayed with no trouble?
RexOnRoids
Not sure. Are you getting any errors? If you set a breakpoint, is the returned UIImage* a valid pointer (i.e. not nil)? Maybe your path is invalid for some reason.
Shaggy Frog
@RexOnRoids, perhaps you use wrong path, show the loading code please.
Valerii Hiora