Working with cached UIImage s
Hi all!
My in-the-making iPhone app is driving me crazy.
I have a custom view hierarchy, managed by a UINavigationController. When the user steps back to a previous view, I release the old view, since it won't be used any longer, and the at the bottom level the views tend to get quite heavy-weight.
But then, when I load a new view of the same kind (but different data), I always run into "EXC_BAD_ACCESS". Debugging revealed the exception is raised when I'm trying to UIImages with a same file as it has been in the unloaded view.
I load the images with [UIImage imageNamed:], and I suppose EXC_BAD_ACCESS comes from the unloading/caching conflict, but I can't really figure out how to resolve it.
(If I don't call release on the old views, sooner or later the app runs out of memory, and I get "EXC_BAD_ACCESS" again)
What is "the nice way" to unload a view, or how can I check if the cache for an image is still valid? (or even better, how can I get the framework to do this automatically for me?)
Thanks,
shinjin
|