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?
CodePudding user response:
Ok, I found the solution.
- 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
- Create a function in that plugin which uses NSSavePanel.
- 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.