![](/img/trans.png)
[英]Swift: Type 'ViewController' does not conform to protocol 'UIPageViewControllerDataSource'
[英]Swift ViewController, objective C protocol, Type 'ViewController' does not conform to protocol 'MyProtocolDelegate'
我正在研究混合项目,它具有swift ViewController,使用C ++代码和目标C类作为C ++类包装器的角色。 到目前为止开发的部分工作。 我在Objective C中添加了简单的协议,它只声明了一个方法:
@protocol MyProtocolDelegate <NSObject>
- (void)updateCount:(int)count;
@end
@interface CvVideoCameraWrapper : NSObject
@property (weak,nonatomic) id <MyProtocolDelegate> delegate;
//remaining of my interface
@end
在swift代码中,我将MyProtocolDelegate添加到ViewController遵守并添加的其他协议:
class ViewController: UIViewController, CvVideoCameraDelegate, UITextFieldDelegate, MyProtocolDelegate{
func updateCount(count:Int)
{
return
}
override func viewDidLoad() {
super.viewDidLoad()
self.typedName.delegate = self // this one works
self.videoCameraWrapper.delegate = self
// remaining of my viewDidLoad
}
//remaining of my ViewController
}
编译器显示错误:类型'ViewController'不符合协议'MyProtocolDelegate'
我不知道在Objective C和swift匹配中声明的委托方法签名,如果在Objective C中的int类型和swift中的int是相同的,但是我知道swift做了swift和我的其他快速,客观的C和C ++工作请指出此协议使用有什么问题
swift类型Int32是obj-c int的正确等价物
但是你应该使用C类型的别名,以避免混淆。 在你的例子中它将是
func updateCount(count:CInt)
{
return
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.