1

As title,my app was worked well before opened sandbox,after that,it can't read any data.How can I get access for ~/Library and it's sub folders?

Lau Cherish
  • 101
  • 9

1 Answers1

4

The purpose of the sandbox is to prevent an application accessing files without the users explicit permission.

To get that permission you need to display a standard open dialog and request the user select the file or folder you wish to access. You can customise the dialog to make your intentions clear.

Once the user has selected the file/folder you can save a bookmark to it allowing your app to access it in future without asking for the user's permission each time.

This is quite a large topic and one you need to understand to write applications for Apple's sandboxed environment.

You can find details on how to do all of this in Apple's documentation; read up on the sandbox, bookmarks etc. SO and the Apple Dev Forums are also good places for information. If you get stuck once you have some code ask another question showing your code and explain your problem.

HTH

CRD
  • 52,522
  • 5
  • 70
  • 86
  • Yes,it's a way to have permission,but I hope to access ~/Library/ and its subfolders without open folders and read some .plist file to get data.Is there any way? – Lau Cherish Aug 18 '15 at 14:58
  • No, you need to obtain the user's permission, as above. This is a cornestone of the sandbox design - no unrestricted access to user's files. – CRD Aug 18 '15 at 16:16
  • @CarlaCamargo - Not sure what you are asking, using the standard file dialog allows the user to select the file/folder and hence give the app access permission. If this doesn't answer your question you should create a proper question if you can't find an answer already on SO. – CRD Sep 24 '19 at 19:35