IPhone - Loading local images from local xml file
Why can I download a local XML file from the main package, but I cannot download images?
NSString * path = [[NSBundle mainBundle] resourcePath];
This is loading (I know because I can trace it) / Users / me / Library / Application Support / iPhone Simulator / User / Applications / 5B888456-40FF-4C72-A2ED-5D5CFA287777 / MyApp.app / test.xml
This image is never loaded (nor is the image): / Users / me / Library / Application Support / iPhone Simulator / User / Applications / 5B888456-40FF-4C72-A2ED-5D5CFA287777 / MyApp.app / background.png
There are two possibilities here:
1) Either your image file name does not match. This means that the filename is case sensitive. Thus, perhaps we are talking about small small letters.
2) You may not have noted the target name from the image property. This means that your images are not part of the purpose of the project you are compiling. To verify this, right click on any image name inside your Xcode object -> Select Get Info -> Select Target Tabs in File Info dialog -> Check Checkbox Status next to Target Name / s. In case it is selected / checked, there is a strange problem. But if it is unselected / unchecked it means the image is not added to the package file that is created after compilation.
The third possibility here is that you may not have added the image you have in mind. Recheck the project hierarchy and see if all the resources are there or not.
a source to share
Sort of
UIImage *testimg = [UIImage imageNamed:myfilename];
if (nil==testimg) [testimg initWithContentsOfURL:myurl];
I'm far from the compiler right now, so I can't check if you need to load it into an NSData object before making an image of it. You should also put initWithContents ... in try ... catch ... finally block.
a source to share