nhatlee
(Lee)
1
Hi all,
I have a swift protocol which need use in objective c code. The protocol is:
@objc public protocol MyProtocol {
var Id: String {get}
}
And into the header file of objective-c, I have a method:
- (void)trackFlow:(MyProtocol *)flow //Error: Expected a type
What I am wrong here? or we cannot use Swift's protocol into the header file of objective c?
- (void)trackFlow:(id<MyProtocol>)flow;
Also you need to import targetName-Swift.h // replace with your target's name.
1 Like
nhatlee
(Lee)
3
import targetName-Swift.h
just in .m
file. But I need to use the protocol in .h
file
nhatlee
(Lee)
4
@linqingmo you right.Thanks for your help.