I am working on mixed project which has swift ViewController, Uses C++ code and objective C Class in the role of wrapper for C++ classes. The part developed so far worked. I have added simple protocol in Objective C, which declares just one method:
@protocol MyProtocolDelegate <NSObject>
- (void)updateCount:(int)count;
@end
@interface CvVideoCameraWrapper : NSObject
@property (weak,nonatomic) id <MyProtocolDelegate> delegate;
//remaining of my interface
@end
In the swift code I added MyProtocolDelegate to other protocols ViewController complies to and added :
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
}
Compiler shows error: Type 'ViewController' does not conform to protocol 'MyProtocolDelegate'
I don't know it the delegate method signature declared in objective C and swift match, if type int in objective C and Int in swift are the same, but I understand that swift does the bridging and my other interaction of swift, objective C and C++ works Please point out what is wrong with this protocol use
int
is equivalent to SwiftInt32
I believe. – danMyProtocolDelegate
– chengsamNSInteger
in your protocol method declaration. – AdamPro13