I create a class that implements both protocols AVCaptureFileOutputDelegateand AVCaptureVideoDataOutputSampleBufferDelegatein Swift 2 (beta 3), but I get a compiler error because both protocols define very similar functions (intentionally, there are examples of Objective-C classes that implement both protocols )
Extensions of the conflicting protocol AVCaptureFileOutputDelegate captureOutput (_: didOutputSampleBuffer: fromConnection :) and AVCaptureVideoDataOutputSampleBufferDelegate captureOutput (_: didOutputSampleBuffer: fromConnection :) . The only difference in function signatures is the type of argument captureOutput( AVCaptureFileOutputand, AVCaptureOutputaccordingly).
I thought using AVCaptureFileOutputin my function definition might work, since it is a subclass AVCaptureOutput, but the compiler still reports an error:
Objective-C method 'captureOutput:didOutputSampleBuffer:fromConnection:' provided by method 'captureOutput(_:didOutputSampleBuffer:fromConnection:)' conflicts with optional requirement method 'captureOutput(_:didOutputSampleBuffer:fromConnection:)' in protocol 'AVCaptureVideoDataOutputSampleBufferDelegate'
Is there a way around this or getting the compiler to use this function for both protocols? Any idea if this is just a problem with Swift 2.0 to be reported on, or an area where Swift has a different approach than the one commonly used in Objective-C?
Thank.
source
share