title: How to convert CMSampleBuffer to CMAttachmentBearer in swift
body: <p>I'm new of swift, I want to call function <code>CMCopyDictionaryOfAttachments</code> in <code>(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection</code> delegate</p>
  
  <p>Codes of mine:</p>
  
  <pre><code>// MARK: Delegates
  
  func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) {
      // got an image
      let pixelBuffer : CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)
      let attachments : CFDictionaryRef = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, sampleBuffer, CMAttachmentMode( kCMAttachmentMode_ShouldPropagate)) as CFDictionaryRef!
  
  }
  </code></pre>
  
  <p>This got an error by xcode :<code>'CMSampleBuffer' is not identical to 'CMAttachmentBearer'</code>
  so how can I use sampleBuffer as target, this code works if written in objective-c</p>