Handling out of memory errors in iPhone

Posted by hgpc on Stack Overflow See other posts from Stack Overflow or by hgpc
Published on 2010-05-07T17:40:44Z Indexed on 2010/05/07 17:48 UTC
Read the original article Hit count: 149

I would like to handle out of memory errors in iPhone to execute logic with lesser memory requirements in case I run of of memory. In particular, I would like to do something very similar to the followin pseudo-code:

UIImage* image;
try  {
    image = [UIImage imageNamed:@"high_quality_image.png"];
} catch (OutOfMemoryException e) {
    image = [UIImage imageNamed:@"low_quality_image.jpg"];
}

First I attempt to load a high-quality image, and if I run out of memory while doing it, then I use a lower quality image.

Would this be possible?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiimage