I am trying to write a command-line tool where I would like to access certain files that the user provides. For example, I want this to be possible:
$ readOrWriteTo /some/path/to/some/file
When in sandboxed mode, I cannot read and write the file because I do not have permission for this. This is OK, but I would like to ask the user to grant permission to selected files. When developing a UI based app, this is possible using the NSDocumentController
, which then returns a security scoped URL. Is there some method to get such a security scoped URL without a document picker? I know that other applications do this, for example when opening Matlab the first time I got a prompt that went something like "Do you want to allow Matlab to access 'Documents'?"