2
votes

A sandboxed App must use Security Scoped Bookmarks in order to save its file access privileges over restarts. The NSURL docs say:

You must balance every call to the startAccessingSecurityScopedResource method with a corresponding call to the stopAccessingSecurityScopedResource method

But I can't see from the docs if I must call the stopAccessing method on the exact same NSURL object that I obtained by resolving a bookmark. (Are these 'magic' NSURL-objects with special properties?)

I would like to call stopAccessing on new NSURL objects, generated from the file path. Of course these point to the same resource. But does it have the same effect?

How can I see if access to a NSURL resource has been stopped?

2

2 Answers

1
votes

I'm pretty sure there is metadata in the NSURL object with some kind of token granting access to that resource.

I don't think what you're proposing is the suggested way of doing it, but give it a shot and see if it works.

1
votes

"How can I see if access to a NSURL resource has been stopped?"

stopAccessingSecurityScopedResource is a void method, not boolean, and there seems to be no way to test the resource to see if it has been "stopped".

  • (void)stopAccessingSecurityScopedResource

I conclude that you must keep track of it yourself.