Please help me to refactor this code, it does not work, I have searched in the internet but did not found any solution. I could not refactor it by myself.
This line:
imageOutput.captureStillImageAsynchronously(from: connection) { (sampleBuffer, error) -> Void in
throws this error:
Value of type 'AVCapturePhotoOutput' has no member 'captureStillImageAsynchronously'
imageOutput.captureStillImageAsynchronously(from: connection) { (sampleBuffer, error) -> Void in
if (sampleBuffer == nil || error != nil) {
DispatchQueue.main.async {
completion(nil, error)
}
return
}
guard let data = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: sampleBuffer!, previewPhotoSampleBuffer: nil) else {
DispatchQueue.main.async {
completion(nil, StillImageError.noData)
}
return
}
guard let image = UIImage(data: data) else {
DispatchQueue.main.async {
completion(nil, StillImageError.noImage)
}
return
}
var saver = ImageSaver()
.onSuccess { image, assetId in
completion(assetId, nil)
}
.onFailure { error in
}
saver = saver.save(image, filter: nil)
}