NSSAVEPANEL用于MAC催化剂?

发布于 2025-02-10 22:41:12 字数 323 浏览 0 评论 0 原文

目标:MAC催化剂的沙盒应用。我需要创建一个文件以在外部驱动器上编写数据。

据我了解,应该有某种对话框授予将数据写入App Sandbox之外的特定位置的权限。 我应该使用哪种对话?

通常,我遵循此过程:在应用程序文档目录中创建一个文件,然后使用 [uidocumentPickerviewController alloc] InitforeforexportingUrls 将此文件移动到沙盒外面。

但是现在,我需要创建一个用于在外部驱动器上写入的文件(在文档目录中无法创建文件,因为它将超过内部存储容量,但是外部驱动器足够大)。应该使用什么“保存文件对话框”?

Objective: a sandboxed application for Mac Catalyst. I need to create a file for writing data on external drive.

As far as I understand, there should be some kind of dialog which grants permission to write data to a specific location outside of the app sandbox.
What kind of dialog should I use?

Usually I followed this procedure: create a file in the app documents directory and then use [UIDocumentPickerViewController alloc] initForExportingURLs to move this file outside of the sandbox.

But now I need to create a file for writing on external drive instead (file cannot be created in documents directory because it will exceed internal storage capacity, but external drive is big enough). What "save file dialog" should be used for that?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏剧牡丹亭 2025-02-17 22:41:13

好的,我找到了解决方案。

  1. 将插件添加到MAC Catalyst项目中,该插件允许使用AppKit功能(在&appkit/nsssavepanel.h>中声明NSSavePanel。详细说明如何在此处添加此类插件:
  2. 在使用NSSAVEPANEL的该插件中创建一个函数。
  3. 从主MAC Catalyst应用程序调用此插件功能。

使用这种方法可以显示NSSAVEPANEL,并且所选文件具有书写所需的所有必要权限。

Ok, I found the solution.

  1. Add a plugin to the Mac Catalyst project which allows usage of AppKit functions (NSSavePanel is declared in <AppKit/NSSavePanel.h>). Detailed explanation how to add such plugin is here: https://www.highcaffeinecontent.com/blog/20190607-Beyond-the-Checkbox-with-Catalyst-and-AppKit
  2. Create a function in that plugin which uses NSSavePanel.
  3. Call this plugin function from main Mac Catalyst app.

Using this approach makes NSSavePanel to be displayed, and the chosen file has all necessary permissions for writing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文