Question

After obtaining a security scoped bookmark to a file, I am seeing mixed results with the bookmark after a user moves the file associated with the bookmark to a different location.

What I am seeing:

  • If the user moves the file, the bookmark resolves correctly to the
    new location. However, once moved, if the user makes a change and
    saves, the bookmark does not resolve and gives an error that the
    file does not exist.
  • If the user makes changes to the file and saves, the bookmark resolves correctly. If the user moves the file after they save, the bookmark no longer resolves and gives an error that the file doesn't exist.

Based on what I am seeing, it makes me think bookmarks don't work they way I think they do under sandboxing. However, I have played with a few other sandbox apps and they seem to handle it fine.

UPDATE:

  • The URL is to a document for my app.
  • All of the modify/saving that happens all goes through the normal NSDocument plumbing.
Was it helpful?

Solution

Yes, security scoped-bookmarks do remain valid after a user moves a file.

After some experimenting, it seems to take the OS a small amount of time to update whatever resource it uses to help with resolving bookmarks. It seems that I was resolving bookmarks too soon after moving the files associated with them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top