On Sep 6, 2016, at 20:59 , Graham Cox <graham....@bigpond.com> wrote:
> 
> I’m having trouble with security-scoped bookmarks in a sandboxed app.

My understanding of security-scoped bookmarks (meaning: this used to be true ~2 
years ago, but I haven’t tried recently to see if it’s still true) is that it’s 
not legal to re-create the bookmark data from a reconstituted security-scoped 
URL.

That is, the “fresh” security-scoped URL you get from NSOpen/SavePanel has 
these characteristics:

(a) you can create bookmark data that contains the security scoping for later 
reconstitution

(b) it doesn’t matter whether you issue “startAccessingSecurityScopedResource” 
or not

When you recreate a security-scoped URL from bookmark data:

(a) you cannot create new bookmark data that contains the security scoping

(b) you must issue “startAccessingSecurityScopedResource”.

In other words, don’t create the bookmark data every time in ‘encodeWithCoder’. 
Instead, create it once when you first get the URL from NSOpen/SavePanel, store 
it as a property, and archive that NSData object.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to