Pregunta

How can I tell which paths have been granted access by the user? I know that with NSOpenPanel, the sandbox is automatically expanded to allow access to the directory the user chooses. Is this information stored anywhere so I can know whether I need to throw up an NSOpenPanel or not?

Or do I need to track it locally in NSUserDefaults or something?

¿Fue útil?

Solución

You are responsible to store already-granted paths using the Secure Bookmarks, read NSURL documentation.

If you need to access to a path check if you have it on secured bookmarks (stored for example inside NSUserDefaults) if you have reuse it otherwise show the open panel

Otros consejos

If you need to know whether the current execution of your app can access a particular path you can call access - see the unix man pages section 2. You can test for read, write and execute access, and the result reflects the current sandbox.

If you want to preserve access between executions of your app then you need to create security scoped bookmarks and stored them in user defaults or some other file.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top