My mac os app get a NSURL of alias by user interaction (drag & drop), so the app have the permission to read the alias file, but it doesn't have permission to read the origianl file within app sandbox (Mac OS X 10.7/8).
I resolve the alias by
NSData* bookmark = [NSURL bookmarkDataWithContentsOfURL:aliasURL error:nil];
origURL = [NSURL URLByResolvingBookmarkData:bookmark
options:NSURLBookmarkResolutionWithoutUI
relativeToURL:nil
bookmarkDataIsStale:nil
error:&error];
When I try to read origURL file, I get the error: The file couldn’t be opened because you don’t have permission to view it
.
I aslo tried call the start/stopAccessingSecurityScopedResource
on the origURL but no help.
I also tried resolving bookmark data with NSURLBookmarkResolutionWithSecurityScope
option, but get "The file couldn’t be opened because it isn’t in the correct format."
error from URLByResolvingBookmarkData method.
So, How do it? Thanks.