initWithContentsOfFile:
Initializes and returns the image object with the contents of the specified file.
- (id)initWithContentsOfFile:(NSString *)path
Parameters
- path
- The path to the file. This path should include the filename extension that identifies the type of the image data.
Return Value of [UIImage initWithContentsOfFile]
An initialized
UIImage
object, or nil
if the method could not find the file or initialize the image from its contents.Discussion of [UIImage initWithContentsOfFile]
This method loads the image data into memory and marks it as purgeable. If the data is purged and needs to be reloaded, the image object loads that data again from the specified path.
Example of [UIImage initWithContentsOfFile]
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"];
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:thePath"];
controller.productImg.image = prodImg;
[prodImg release];