views:

27

answers:

1

what is the best method to display about 300 png images into a UITableView..

i dont wanna display them at the same time... i have 3 tableViewControllers that will each display about 100 imgaes.. (its for a catalog so the images are important to display) i used [uiimage imageNamed:] but that method caches the images and they dont get released so the memory usage is big.... is there any way to release the cache when the nav controller pushes a different view controller?

i also tried [uiimage alloc] initWithContentsOfFile] but the images wont display....

any help?

A: 
[UIImage imageNamed:@"foo.png"];

is equivalent to

[[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"foo" ofType:@"png"]] autorelease];

except it does not cache the image.

If you write your own caching function, you can purge it at any time. When you need an image, check an NSMutableDictionary by name. If it does not exist, load the image normally and add it to the dictionary with the name as a key. To flush the cache, remove all objects from the dictionary.

drawnonward