Reputation: 533
I am saving an image from to my apps directory, and when I try to retrieve it with imageWithContentsOfFile it returns a nil image. I have verified that the file exists in the apps container and that the path I use is correct. Any ideas?
If there is any code that you need let me know. I am not sure what you would need to see.
Thanks
BTW here is the exact syntax I use for loading the image from the path.
UIImage *image = [UIImage imageWithContentsOfFile:path];
Upvotes: 1
Views: 301
Reputation: 17043
The first thing you should do is to check is it a file input/output issue or an image issue. So try to read your file data with
NSData *fileData = [NSData dataWithContentsOfFile:path];
If fileData is nil or its length is 0 then you should recheck the path and the way you are storing a data.
If fileData is ok try
image = [[UIImage alloc] initWithData:fileData];
to check a data to image conversion. Is it possible to open file with some MacOS image viewer?
Upvotes: 1