简体   繁体   English

错误桥接 Obj-C 代码和 Swift:方法“Z”提供的方法“U”与协议“Y”中的可选要求方法“X”冲突

[英]Error bridging Obj-C code and Swift: method "U" provided by method "Z" conflicts with optional requirement method "X" in protocol "Y"

The goal is to incorporate PBJVision , an Objective-C library for capturing photos and videos, into a Swift app.目标是将PBJVision (一个用于捕捉照片和视频的 Objective-C 库)合并到一个 Swift 应用程序中。

Unfortunately, we are seeing this error:不幸的是,我们看到了这个错误:

Objective-C method 'vision:capturedVideo:error:' provided by method 'vision(:capturedVideo:error:)' conflicts with optional requirement method 'vision(:capturedVideo:error:)' in protocol 'PBJVisionDelegate'由方法“vision(:capturedVideo:error:)”提供的Objective-C方法“vision:capturedVideo:error:”与协议“PBJVisionDelegate”中的可选要求方法“vision(:capturedVideo:error:)”冲突

Here's the delegate method triggering the error:这是触发错误的委托方法:

func vision(vision: PBJVision, capturedVideo: NSDictionary, error: NSError) {
    println("Encountered error during recording \(error)")
    println("Captured video")
}

It seems like the problem was patched a while ago , but we are on the new version (ie, changes mentioned are already incorporated) and still seeing the error.问题似乎是在不久前修补的,但我们使用的是新版本(即,提到的更改已经合并)并且仍然看到错误。

Why is this happening, and how can we fix this?为什么会发生这种情况,我们如何解决这个问题?

It's simply a matter of translating Objective-C into Swift.这只是将 Objective-C 翻译成 Swift 的问题。 The Objective-C declaration looks like this: Objective-C 声明如下所示:

- (void)vision:(PBJVision *)vision capturedPhoto:(nullable NSDictionary *)photoDict error:(nullable NSError *)error;

Therefore, to match it, your declaration should look like this:因此,为了匹配它,您的声明应如下所示:

func vision(vision: PBJVision, capturedVideo videoDict: [NSObject : AnyObject]?, error: NSError?) {
    // ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 协议中方法“”提供的Objective-C方法“:”与协议中的可选需求方法“”冲突 - Objective-C method ':' provided by method ' ' conflicts with optional requirement method ' ' in protocol Objective-C方法与可选的需求方法Swift冲突 - Objective-C method conflicts with optional requirement method Swift 更新到XCode 6.3(Swift 1.2)后,“Objective-C方法与可选的需求方法冲突”错误 - “Objective-C method conflicts with optional requirement method”error after update to XCode 6.3 (Swift 1.2) 在Swift中移植obj-c委托方法 - Porting obj-c delegate method in Swift imagePickerController:didFinishPickingMediaWithInfo与协议'UIImagePickerControllerDelegate'中的可选需求方法冲突 - imagePickerController:didFinishPickingMediaWithInfo conflicts with optional requirement method in protocol 'UIImagePickerControllerDelegate' 调用obj-c中的类方法时出错 - Error calling class method in obj-c 如何从obj-c协议快速实现此方法? - How can I implement this method in swift from obj-c protocol? 具有可空返回值的Obj-c方法未正确转换为swift - Obj-c method with nullable return value not properly converting to swift 如何使用Obj-C中的参数调用Swift方法 - How to invoke a Swift method with parameters from Obj-C Obj-C实例方法返回从Swift调用的instanceType-函数产生预期的类型'UIImage!' 错误 - Obj-C Instance method returning a instanceType called from Swift - Function produces expected type 'UIImage!' error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM