0

我有一个NSMutableDictionaryNSMutableArray该应用程序允许用户使用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,它将不显示任何图像。我想知道关于沙盒应用程序有什么我不知道的吗?

感谢您的意见。

4

0 回答 0