gpt4 book ai didi

objective-c - 正确的权利标志将文件保存在同一位置两次

转载 作者:行者123 更新时间:2023-12-03 16:42:47 25 4
gpt4 key购买 nike

我在我的应用中使用 NSSavePanel。在我的 OS X 10.7 上一切正常,但该应用程序被 Apple 拒绝,并给出以下评论:

When exporting for the second time, the previously selected save location does not work. The user has to unselect the location and then select it again in order to have the file written. Please ensure that you have the necessary entitlements.

This review was conducted on an iMac running OS X 10.8.

这是我的保存面板代码:

NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"mov"]];
[savePanel setDirectoryURL:[NSURL URLWithString:@"/Documents"]];
[savePanel setNameFieldStringValue: videoName];

[savePanel beginSheetModalForWindow:window completionHandler:^(NSInteger result){
if (result == NSFileHandlingPanelOKButton) {
NSError *error = nil;
NSString *sourceFilePath = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] resourcePath], videoName];
NSString *destFilePath = [[savePanel URL] path];
NSFileManager *fileManager = [[NSFileManager alloc] init];
if(![fileManager copyItemAtPath:sourceFilePath toPath:destFilePath error:&error])
NSLog(@"%@", error);
}
}];

目前我正在使用这些标志:

 <dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.assets.movies.read-write</key>
<true/>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>

我必须使用什么权利标志来解决此问题?

最佳答案

如果您正在讨论在应用程序的同一运行中保存两次,则不需要任何权利;一旦用户从 NSSavePanel 选择文件,它就会位于您应用的沙箱中。如果保存面板两次显示,这同样适用——它应该“正常工作”。如果连续运行之间的位置相同,并且第二次没有保存面板,则需要将安全范围的书签存储到文件中。

例如,请参阅此问题中给出的示例代码(以及接受的答案中对其的更正):App Sandbox: document-scoped bookmark not resolving; not returning any error

关于objective-c - 正确的权利标志将文件保存在同一位置两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12546766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com