title: SwiftySandboxFileAccess UserDefaults value
body: <p><a href="https://github.com/ConfusedVorlon/SwiftySandboxFileAccess" rel="nofollow noreferrer">SwiftySandboxFileAccess</a> works the first time the user approves the NSOpenPanel selection, but the next time the app opens, the security bookmark doesn't have access even though SwiftySandboxFileAccess thinks it has access just because a value is saved in the <code>UserDefaults</code> I think?</p>
  <p>This is what <code>SwiftySandboxFileAccess</code> is saving in <code>UserDefaults</code></p>
  <pre><code>&quot;bd_file:///Volumes/&quot;: &lt;626f6f6b fc010000 00000410 30000000 75703e99 3136c5a3 905214f4 1d55afdf
   f9680acc 65a5c354 86b39a29 ee2e1683 1c010000 04000000 03030000 00080028 07000000 01010000
   566f6c75 6d657300 04000000 01060000 10000000 08000000 04030000 93d14501 00000000 04000000 
  01060000 2c000000 08000000 00040000 41c188f9 52800000 18000000 01020000 02000000 00000000 
  0f000000 00000000 00000000 00000000 08000000 01090000 66696c65 3a2f2f2f 0c000000 01010000 
  4d616369 6e746f73 68204844 08000000 04030000 0050065e 3a000000 08000000 00040000 41c1ab00 
  f8865976 24000000 01010000 35384630 35383433 2d414237 332d3442 34342d42 3344372d 34374434 
  39373543 46434536 18000000 01020000 81000000 01000000 ef130000 01000000 00000000 00000000 
  01000000 01010000 2f000000 00000000 01050000 a8000000 feffffff 01000000 00000000 0d000000 
  04100000 20000000 00000000 05100000 3c000000 00000000 10100000 58000000 00000000 40100000 
  48000000 00000000 02200000 08010000 00000000 05200000 78000000 00000000 10200000 88000000 
  00000000 11200000 bc000000 00000000 12200000 9c000000 00000000 13200000 ac000000 00000000 
  20200000 e8000000 00000000 30200000 14010000 00000000 10d00000 04000000 00000000&gt;
  </code></pre>
  <ol>
  <li>What's the <code>bd_</code> it added at the beginning of the <code>file://</code> path?</li>
  <li>What're all these 8 bit things?</li>
  </ol>
  <hr />
  <p>More Context:</p>
  <p>This is how I'm trying to use the security bookmark:</p>
  <pre class="lang-swift prettyprint-override"><code>  func accessRunFileVacuum(args: VacuumCli) {
      let access = SandboxFileAccess()
      let success = access.access(
  
        fileURL: URL(fileURLWithPath: &quot;/Volumes&quot;),
        askIfNecessary: true,
        persistPermission: true, with: {
        
        print(&quot;access the URL here&quot;)
        self.runFileVacuumCLI(args)
  
      })
  
      print(&quot; pickFile success: \(success)&quot;)
    }
  </code></pre>
  <p><code>&quot;access the URL here&quot;</code> ..., <em>URL</em>... hum... </p>
  <p>from:
  <a href="https://github.com/ConfusedVorlon/SwiftySandboxFileAccess/blob/master/SwiftySandboxFileAccessDemo/SwiftySandboxDemo/Manager.swift#L42" rel="nofollow noreferrer">https://github.com/ConfusedVorlon/SwiftySandboxFileAccess/blob/master/SwiftySandboxFileAccessDemo/SwiftySandboxDemo/Manager.swift#L42</a></p>
  <p>I was reading a related security bookmarks ticket and it mentioned that the Security Bookmark needs to be saved as a URL and then passed into the sub-process that wants to use it:
  <a href="https://stackoverflow.com/a/27321020/1762493">https://stackoverflow.com/a/27321020/1762493</a></p>
  <p>the <code>with: {}</code> block is wrapped in <code>startAccessingSecurityScopedResource</code>/<code>stopAccessingSecurityScopedResource</code> already via SwiftySandboxFileAccess seen here: <a href="https://github.com/ConfusedVorlon/SwiftySandboxFileAccess/blob/master/SwiftySandboxFileAccess/Classes/SandboxFileAccess.swift#L87" rel="nofollow noreferrer">https://github.com/ConfusedVorlon/SwiftySandboxFileAccess/blob/master/SwiftySandboxFileAccess/Classes/SandboxFileAccess.swift#L87</a></p>
  <p><code>runFileVacuumCLI()</code> runs as a Queue Operation:</p>
  <pre class="lang-swift prettyprint-override"><code>  func runFileVacuumCLI(_ args: VacuumCli) {
      checkVolumesAccess()
  
      if queue.operationCount &lt; 1 {
  
        fvOperation = FileVacuumOperation(vacuumCli: args)
        queue.addOperations([fvOperation], waitUntilFinished: false)
        
      }
    }
  </code></pre>