title: CGPDFDocumentCreateWithURL fails (Toll-Free bridging of NSURL to CFURLRef)
body: <p>I've got the following function:</p>
  
  <pre><code>- (void)loadPdfFromPath:(NSString*)path
  {   
      NSURL *pathUrl = [NSURL URLWithString:path];
  
      _pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)pathUrl);
  }
  </code></pre>
  
  <p>Which from the documentation I'm lead to believe will work because you can case from an <code>NSURL*</code> to a <code>CFURLRef</code> via <a href="https://developer.apple.com/library/mac/#documentation/General/Conceptual/CocoaEncyclopedia/Toll-FreeBridgin/Toll-FreeBridgin.html#//apple_ref/doc/uid/TP40010810-CH2" rel="nofollow">Toll-Free Bridging</a>. However, this function fails, and I get the following output in the log:</p>
  
  <blockquote>
    <p>CFURLCreateDataAndPropertiesFromResource: error code -15.</p>
  </blockquote>
  
  <p>NB: -15 = <code>kCFURLImproperArgumentsError</code></p>
  
  <p>However, if I create an actual <code>CFURLRef</code>, it works absolutely fine:</p>
  
  <pre><code>- (void)loadPdfFromPath:(NSString*)path
  {
      CGPDFDocumentRelease(_pdfDocument);
  
      CFStringRef cgPath = CFStringCreateWithCString(NULL, [path UTF8String], kCFStringEncodingUTF8);
  
      CFURLRef url = CFURLCreateWithFileSystemPath(NULL, cgPath, kCFURLPOSIXPathStyle, 0);
  
      _pdfDocument = CGPDFDocumentCreateWithURL(url);
  
      CFRelease(url);
      CFRelease(cgPath)
  }
  </code></pre>
  
  <p>What am I missing? I'm happy to keep the second function in my code, but I'd rather know why the first one is failing.</p>