How to fix this in Swift 6 mode?
import AVFoundation
actor A: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
func foo(_ sampleBuffer: CMSampleBuffer) {
// ...
}
nonisolated func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
Task {
await foo(sampleBuffer)
// ❌ Passing closure as a 'sending' parameter risks causing data races between code in the current task and concurrent execution of the closure
}
}
}