Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In my test program this works fine. I suspect the append of the file name to the URL is failing in your case (but that's a huge guess) because it's the only thing that seems materially different.</p> <p>I notice that the url for a security resolved location is: file://localhost/Users/dad/Desktop/TestFolder?applesecurityscope=343335323030663066393432306234363030346263613464636464643130663635353065373030373b30303030303030303b303030303030303030303030303032303b636f6d2e6170706c652e6170702d73616e64626f782e726561642d77726974653b30303030303030313b30313030303030323b303030303030303030326461363838663b2f75736572732f74796c65722f6465736b746f702f74657374666f6c646572</p> <p>which is the other reason I wonder if the append is the issue.</p> <p>In my test I have the user choose the folder, create the security scoped bookmark and then save that in user defaults.</p> <p>Then I quit &amp; relaunch the app and via a menu command I get that bookmark and then resolve it. Then I added a case where I use the resolved bookmark to a folder and make a new bookmark to the file within the folder.</p> <p>It seems to work fine.</p> <hr> <p>In my test where it's working I'm getting the path to the file like this:</p> <pre><code>NSURL * resolvedURL = [NSURL URLByResolvingBookmarkData: data options: NSURLBookmarkResolutionWithSecurityScope relativeToURL: nil bookmarkDataIsStale: &amp;isStale error: &amp;error]; ... // (error checking) [resolvedURL startAccessingSecurityScopedResource]; NSArray * files = [[NSFileManager defaultManager] contentsOfDirectoryAtURL: resolvedURL includingPropertiesForKeys: @[NSURLLocalizedNameKey, NSURLCreationDateKey] options: NSDirectoryEnumerationSkipsHiddenFiles error: &amp;error]; if ( files != nil ) { NSURL * fileURL = [files objectAtIndex: 0]; // hard coded for my quick test NSData * newData = [fileURL bookmarkDataWithOptions: NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys: nil relativeToURL: nil error: &amp;error]; if ( newData != nil ) { NSLog(@"it's good!"); } .... // error checking and logging. </code></pre> <p>if that doesn't get you on the right track, I'm going to need to see more code (you'll probably need to make a simple example).</p> <p>Note that in my case I'm resolving the bookmark and calling <code>startAccessingSecurityScopedResource</code> even when I just got the url &amp; created the bookmark (when I tried to create a bookmark from the path I'd just acquired from PowerBox (openPanel) it failed with an error 256).</p> <p>Some configuration details: OS X 10.8.4, Xcode 5 (first public release from today 9/18/2013).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload