我有一个 NSMutableArray NSMutableDictionary 。该应用程序允许用户使用 plist 将数组保存为 XML 项目文件。在应用程序进行沙盒处理之前,一切正常。字典包含用于存储文件名,图像宽度,图像高度,文件路径...的键,所有这些都是字符串。
现在,如果我在使用 NSOpenPanel 读取项目文件时应用程序是沙箱,那么事情就不顺利了。应用程序可以读取项目文件,因为它启用 com.apple.security.files.user-selected.read-write 。但它无法使用文件路径创建图像。
- 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 {
...
}
}
因此,如果应用程序将文件路径传递给 NSImage ,则它将不显示任何图像。我想知道是否有一些我不了解沙盒应用程序的东西?
感谢您的建议。