NSProgress不使用沙盒项目?

发布于 2025-02-06 19:06:27 字数 1310 浏览 0 评论 0原文

我正在创建一个nsprogress对象,以在下载目录中显示一个文件下的进度指标。授权包括com.apple.security.files.downloads.read-write。 该指示器未显示nsprogressfileurlkey指向沙盒文件路径,例如/users/mdbraber/mdbraber/library/containers/containers/comcom.mdbraber.testapp/datapapp/data/data/data/downa/test.pptx.pptx.downloads /代码>。当nsprogressfileurlkey指向Sandbox链接到EG /users/mdbraber/mdbraber/downloads/test.pptx.download时,它确实可以工作

。为NSProgressFileUrlkey使用其他功能来制作这项工作吗?

#define KdownloadsPath NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).firstObject

_downloadedPath = [KdownloadsPath stringByAppendingPathComponent:fileName];
_downloadingPath = [_downloadedPath stringByAppendingString:@".download"];

NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
        @"NSProgressFileOperationKindDownloading", @"NSProgressFileOperationKindKey",
        [NSURL fileURLWithPath:_downloadingPath], @"NSProgressFileURLKey",
        nil];

self.progress = [[NSProgress alloc] initWithParent:nil userInfo:info];
[self.progress setKind:@"NSProgressKindFile"];
[self.progress setPausable:NO];
[self.progress setCancellable:YES];
[self.progress setTotalUnitCount:_totalBytes];
[self.progress publish];

(更新进度指标发生在其他地方)

I'm creating an NSProgress object to show a progress indicator underneat a file in my Downloads directory. The entitlements includes com.apple.security.files.downloads.read-write.
The indicator does not show when NSProgressFileURLKey points to the sandboxed file path, e.g. /Users/mdbraber/Library/Containers/com.mdbraber.TestApp/Data/Downloads/Test.pptx.download. It does work when NSProgressFileURLKey points to the direct download location which the sandbox links to e.g. /Users/mdbraber/Downloads/Test.pptx.download

Is this a bug or should I use something else for NSProgressFileURLKey to make this work?

#define KdownloadsPath NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).firstObject

_downloadedPath = [KdownloadsPath stringByAppendingPathComponent:fileName];
_downloadingPath = [_downloadedPath stringByAppendingString:@".download"];

NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
        @"NSProgressFileOperationKindDownloading", @"NSProgressFileOperationKindKey",
        [NSURL fileURLWithPath:_downloadingPath], @"NSProgressFileURLKey",
        nil];

self.progress = [[NSProgress alloc] initWithParent:nil userInfo:info];
[self.progress setKind:@"NSProgressKindFile"];
[self.progress setPausable:NO];
[self.progress setCancellable:YES];
[self.progress setTotalUnitCount:_totalBytes];
[self.progress publish];

(updating the progress indicator happens elsewhere)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文