NSError *error = nil; NSURLBookmarkCreationOptions options = NSURLBookmarkCreationSuitableForBookmarkFile | NSURLBookmarkCreationWithSecurityScope; NSData *bookmarkData = [self.url bookmarkDataWithOptions:options includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
This code works fine in a non-sandboxed app (without the NSURLBookmarkCreationWithSecurityScope option). It also works fine in a sandboxed app, when I leave out the NSURLBookmarkCreationWithSecurityScope. However when I execute the code as written above in a sandboxed app the bookmarkDataWithOptions:etc… method returns nil, and an error: Domain=NSCocoaErrorDomain Code=256 "The file “xxx” couldn’t be opened." self.url is a copy of a fileURL requested from an NSDocument. I've added the com.apple.security.files.bookmarks.app-scope entitlement to the entitlements file, and checked "Use entitlements file". I want to create app scope bookmarks and I think the code above is correct. Is there anything else that needs to be set up, or am I misunderstanding anything? I can't find anything in the docs or by searching for similar problems (they turn up, but nowhere do I see a replica if this precise case, nor any pointers in somewhat similar cases that led me to a solution). -António _______________________________________________ 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