title: Taking photo with custom camera iOS 11.0 Swift 4. Update error
body: <p>I have a custom camera in my app and it worked fine, but after the new update I am getting this error:</p>
  
  <blockquote>
    <p>'jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)' was deprecated in iOS 11.0: Use -[AVCapturePhoto fileDataRepresentation] instead.</p>
  </blockquote>
  
  <p>This is the line where I'm getting that error:</p>
  
  <pre><code>    guard let imageData =
          AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: photoSampleBuffer, previewPhotoSampleBuffer: previewPhotoSampleBuffer) else {
              return
      }
  </code></pre>
  
  <p>This is my whole function (if needed):</p>
  
  <pre><code>//Take pic function
  func photoOutput(_ captureOutput: AVCapturePhotoOutput,
                   didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?,
                   previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?,
                   resolvedSettings: AVCaptureResolvedPhotoSettings,
                   bracketSettings: AVCaptureBracketedStillImageSettings?,
                   error: Error?) {
  
  
      // Make sure we get some photo sample buffer
      guard error == nil,
          let photoSampleBuffer = photoSampleBuffer else {
              print("Error capturing photo: \(String(describing: error))")
              return
      }
      // Convert photo same buffer to a jpeg image data by using // AVCapturePhotoOutput
      guard let imageData =
          AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: photoSampleBuffer, previewPhotoSampleBuffer: previewPhotoSampleBuffer) else {
              return
      }
  
      let dataProvider = CGDataProvider(data: imageData as CFData)
  
      let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.absoluteColorimetric)
  
  
      let image = UIImage(cgImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.right)
  
      self.tempImageView.image = image
  
  }
  </code></pre>
  
  <p>My guestion is: <strong>What should I use instead to make it work?</strong></p>
  
  <p>Thank you.</p>