I have a sandboxed Mac app which I can grant access to a folder using an NSOpenPanel
. Once it’s been granted access it can enumerate the contents of the folder just fine. If I rename the folder while the app is open and then make the app enumerate the folder’s contents again, though, it seems to have lost access.
What’s the recommended way to have an app’s sandbox “track” files as they’re moved around the filesystem? (NSDocument
handles this for you, from what I can tell.) I’ve managed to hack something together with a combination of Dispatch sources and security-scoped bookmarks, but it feels like there must be an easier solution …
There are two standard approaches:
-
Open the item and leave it open while you need it.
-
Use a security-scoped bookmark.
I’m not sure where Dispatch sources come into this, but I wouldn’t consider security-scoped bookmarks to be a hack. Bookmarks were specifically designed to track items across renames, and security-scoped bookmarks are just an extension on that for sandboxed app.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"