I want to maintain a list of folders, in a sandboxed Mac app. To do that, I need to make a security-scoped bookmark, using url.bookmarkData()
.
Is it guaranteed that the Data
returned by this method is always the same byte pattern, for a given file URL?
That is, can I take a new url.bookmarkData()
and test if a [Data]
list contains a security-scoped bookmark for the same URL, by just checking the Data instances? Or do I need to resolve each Data
into a URL
and compare those?
Nope.
Make a sandboxed Mac app. Then:
Use FileManager's url(for:in:appropriateFor:create:)
to get the .downloadsFolder
, and then run it through destinationOfSymbolicLink(atPath:)
to get a URL with a path like "/Users/me/Downloads"
Use NSOpenPanel to ask the user for a file, and choose your Downloads folder. You'll get a URL with a path like "/Users/me/Downloads"
Call .bookmarkData()
on the URLs in #1 and #2. The Data
s you get aren't even the same length.