0

I'm trying to load a PNG image from a local volume. The user chooses the file using a normal NSOpenPanel. After enabling sandbox the init method to load a local file return nil. I'm also trying to use NSURL but i can't figure out how to use for local stored file that are not in remote or in the bundle.

mahal tertin
  • 3,239
  • 24
  • 41
  • 1
    possible duplicate of [can't open image with NSOpenPanel](http://stackoverflow.com/questions/10355591/cant-open-image-with-nsopenpanel) – mahal tertin Mar 18 '14 at 10:07
  • Which code do you use to load image? – Nickolay Olshevsky Mar 18 '14 at 10:09
  • I continue to be unable to load the image. I continue to think it depends by Sandbox. It's not well documented and I'm sure that all the programmer that develop an application in the normal way then need to activate the sandbox will run in these troubles. My code is this: NSString* url = [[NSString stringWithFormat:@"file://localhost%@%@%@", pathWithoutFilename, @"/", imageFileName ]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *nsurl = [NSURL URLWithString:url]; NSImage *sourceImage = [[NSImage alloc] initWithContentsOfURL:nsurl]; –  Mar 23 '14 at 16:25
  • The nsurl points correctly to the image infact i can see it within the preview popup debugging the nsurl object and the path is correct in the format: "file://localhost/Users/myname/etc../file.png" –  Mar 23 '14 at 16:28
  • Maybe I've understood the problem: my app load files from url inside a plist file dropped into it. When i do drag and drop sandbox allow to access to this file but the files specified by paths inside this one are not recognized how allowed by the user and so sandbox block them. How can I avoid to use sandbox? When i disable it Apple reject my app. –  Mar 24 '14 at 09:37

0 Answers0