NSSavePanel for saving a file after sandboxing

265 views Asked by At

I have a mac AVRecording app, which records a video and save it to a location selected via NSSavePanel. It was working fine till I sandboxed the app.

For sandboxing I have added the following entitlements com.apple.security.files.user-selected.read-write com.apple.security.assets.movies.read-write com.apple.security.files.downloads.read-write This enables saving to Downloads and movies folder only.

How is it possible to save my file to any desired location, Desktop, Documents etc ?

1

There are 1 answers

0
gaige On

It's not clear from your question whether you are referring to saving a particular file (in which case you can use the NSSavePanel and manually copy the file using NSFileManager to write the file into the user-specified new file), or whether you are referring to having the user choose a location for all future downloads.

If you want to prompt the user for a location to use for future downloads, you'll need to use the secure bookmark entitlement and secure bookmarks to retain access to the folder.

There's another stackoverflow answer about sandboxing which covers the process of saving and using the secure bookmark.