I have a shoebox type (as opposed to document based) OS X app that stores images in the app's sandbox container.
These images can be shared via Share Extensions (in form of a NSURL) or exported via drag and drop.
When an image is shared to an image editor (e.g. Acorn offers a Share Extension), or dropped on an image editor, the image editor opens the file from within my sandbox container and can now alter, rename or delete this file - which can lead to all kinds of inconstancies in my app.
First, I was surprised, because I thought, files in the sandbox can only be accessed by the app itself. But it seems this is not the case, when I intentionally share the NSURL.
So how can I prevent that someone can alter files in my sandbox container while still offering them for drag and drop and to Share Extensions?
- I tried not sharing NSURLs but NSImages, but many Share Extensions do not work with NSImages, so this is not a good option.
- Is it a possibility to write-protect the files in the sandbox?
- Should I always make a copy of an image to a temporary location, before I offer it for sharing or drag and drop (could be slow for big images?)
I am happy to hear your suggestions or learn more about the problem.