Created
April 11, 2012 14:22
-
-
Save florieger/2359613 to your computer and use it in GitHub Desktop.
Memory Efficient Image Loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - | |
#pragma mark Memory Efficient Image Loading | |
+ (UIImage*)imageWithContentsOfFilename:(NSString*)filename | |
{ | |
NSMutableString* path = [NSMutableString stringWithString:[[NSBundle mainBundle] bundlePath]]; | |
[path appendString:@"/"]; | |
[path appendString:filename]; | |
return [UIImage imageWithContentsOfFile:path]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of [UIImage imageNamed:@"your.png"] which caches the image data,
this method releases the memory of the image immediately after the UIImage object is deallocated.