1
votes

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?

1
show code and error message(s)hoijui
@hoijui No error message.But after I closed sandbox option, it worked well.I think the problem will be on sandbox.Lau Cherish
i don't know how sandbox works, but it sounds like it is meant to be a safe environment, thus it makes sense that it has no access to the normal system. maybe you can read about "cocoa sandbox modifying environment" or something like that.hoijui
Yeah,thanks any way~Lau Cherish
@hoijui It seems to have to ask for permission from apple.Lau Cherish

1 Answers

4
votes

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