In Swift, the best solution is:
let result = vc is MyProtocol
or as?:
if let myVC = vc as? MyProtocol { ... then use myVC that way ... }
But for use, conformsToProtocolyou must note the protocol @objc:
@objc protocol MyProtocol {
func myfunc()
}
(Note that classes and protocols should always start with capital.)
source
share