How can I set image to UIImage
object.
For example:
UIImage *img = [[UIImage alloc] init];
[img setImage:[UIImage imageNamed:@\"anyImageName\"]]
You can set an Image in UIImage object eiter of the following way:
UIImage *imageObject = [UIImage imageNamed:@"imageFileName"];
but by initializing UIImage
Object like this, the image is always stored in cache memory even you make it nil
like imageObject=nil;
Its better to follow this:
NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"imageFilename" ofType:@"imageFile_Extension"];
UIImage *imageObject = [UIImage imageWithContentsOfFile:imageFilePath];
EXAMPLE: NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"abc" ofType:@"png"];
UIImage *imageObject = [UIImage imageWithContentsOfFile:imageFilePath];