NSImage can't load image from file


#1

the image in
NSImage *image = [[NSImage alloc] initWithContentsOfURL:[panel URL]];
has no content. I check the [panel URL] by print out, it is directory to an .png file. The png file can be show with image display softwar.
It is so weird.


#2

This may be caused by sandboxing restrictions. Did you add the image to your project?


#3

This won’t be sandboxing, it’s more than likely user restrictions, OR an incompatible format.

The ones I used for testing were in: /Library/Application Support/Apple/iChat Icons/Flags

They worked fine.

If they don’t (or you don’t have them), try using several different images… Make sure they are in your own folder i.e. ~/

I personally would advise using PNG files and alot of OSX Apps and iPhone Apps use PNG as a standard