Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 同时实现AVCaptureFileOutputDelegate和AVCaptureVideoDataOutputSampleBufferDelegate_Swift_Avfoundation_Swift2 - Fatal编程技术网

Swift 同时实现AVCaptureFileOutputDelegate和AVCaptureVideoDataOutputSampleBufferDelegate

Swift 同时实现AVCaptureFileOutputDelegate和AVCaptureVideoDataOutputSampleBufferDelegate,swift,avfoundation,swift2,Swift,Avfoundation,Swift2,我正在创建一个类来实现Swift 2(beta 3)中的AVCaptureFileOutputDelegate和AVCaptureVideoDataOutputSampleBufferDelegate协议,但由于这两个协议都定义了非常相似的函数,因此我遇到了一个编译器错误(有意这样做;有一些示例Objective-C类实现了这两个协议) 冲突的协议扩展是AVCaptureFileOutputDelegate和AVCaptureVideoDataOutputSampleBufferDelegate

我正在创建一个类来实现Swift 2(beta 3)中的
AVCaptureFileOutputDelegate
AVCaptureVideoDataOutputSampleBufferDelegate
协议,但由于这两个协议都定义了非常相似的函数,因此我遇到了一个编译器错误(有意这样做;有一些示例Objective-C类实现了这两个协议)

冲突的协议扩展是
AVCaptureFileOutputDelegate
AVCaptureVideoDataOutputSampleBufferDelegate
。函数签名的唯一区别是
captureOutput
参数的类型(
AVCaptureFileOutput
AVCaptureOutput

我认为在我的函数定义中使用
AVCaptureFileOutput
可能有效,因为它是
avcapturefoutput
的子类,但编译器仍然报告错误:

Objective-C method 'captureOutput:didOutputSampleBuffer:fromConnection:' provided by method 'captureOutput(_:didOutputSampleBuffer:fromConnection:)' conflicts with optional requirement method 'captureOutput(_:didOutputSampleBuffer:fromConnection:)' in protocol 'AVCaptureVideoDataOutputSampleBufferDelegate'
有没有办法解决这个问题,或者强制编译器对两个协议都使用该函数?是否知道这只是一个应该报告的Swift 2.0问题,或者Swift的方法与Objective-C中通常使用的方法不同


谢谢。

至少考虑到当前的Swift测试版,我找不到解决方法。我使用了一个单独的类作为
AVCaptureFileOutputDelegate
delegate。不优雅,但功能强大。

我想到了另一种方法。我使用AVCaptureVideoDataOutput来处理和提取单个fr的信息ames,在使用AVCaptureMovieOutput将音频/视频写入文件时。也许我可以取消AvCaptureMovieDataOutput,因为capture委托提供对示例缓冲区的访问?没关系,替代方法似乎不起作用。如果我尝试上述方法,则没有可用的图像缓冲区。我可能只需要使用两个委托类如果在同一个类上使用两个单独的扩展名,是否会发生错误?我没有尝试使用最新版本的Swift。但是,当我最初编写本文时,不可能将函数包含在不同的扩展名中,因为编译器在编译过程中仍然识别出冲突。