[英]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.