I have an NSMutableArray of NSMutableDictionary. The application allows the user to save the array as an XML project file with plist. Everything works fine before the application is sandboxed. The dictionary contains keys to store file names, image width, image height, file paths... all as strings.
Now, if I read a project file with NSOpenPanel while the application is sandboxed, things don't go well. The application can read a project file since it enables com.apple.security.files.user-selected.read-write. But it will fail to create an image with a file path.
- tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)TableColumn row:(NSInteger)rowIndex {
NSString *imagename = [[imageArray1 objectAtIndex:rowIndex] objectForKey:key1a];
if ([[TableColumn identifier] isEqualToString:@"images"]) {
if ([self fileExists:imagepath]) {
NSImage *image0 = :[[NSImage alloc] initWithContentsOfFile:imagepath]; // ==> failure
return image0;
} else {
return nil;
}
}
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
NSInteger r1 = [tableview1 selectedRow];
if (r1 >=0) {
NSString *filepath = [[imageArray1 objectAtIndex:r1] objectForKey:key1b];
if ([self fileExists:filepath]) {
pictureimage10.image = [[NSImage alloc] initWithContentsOfFile:filepath]; // ==> failure
} else {
...
}
} else {
...
}
}
So if the application passes a file path to NSImage, it will display no image. I wonder if there's something that I don't know about sandboxing applications?
Thank you for your advice.