I am downloading two images from the web Apple.png and Apple@2x.png. I want to use [UIImage imageNamed:@"Apple.png"]
so it can use the build in features to detect whether it should display either Apple.png or Apple@2x.png.
Now where do I store these images? I read the following in the documentation:
The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle.
Ah so the Application's Main Bundle is the way to go. This is what my code looks like:
NSString *directory = [[NSBundle mainBundle] bundlePath];
NSString *path = [directory stringByAppendingPathComponent:imageName];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:dataFetcher.receivedData attributes:nil];
I checked if the file was created in the folder of the path and that was correct. I also dragged an Example.png in my project file just to see if it got stored in the same folder and that also was correct.
However, [UIImage imageNamed:@"Apple.png"]
, still fails to fetch the images.