@objc public protocol Sound {
@objc optional func woo()
}
public class Foo: NSObject, Sound {
func action() {
((self as Sound).woo ?? default_woo)() // calls `woo` method if available or defaults to default_woo method
}
func default_woo() {
// called if class Foo does not implement `woo` somewhere
}
}
extension Foo {
func woo() {
// code code code
}
}
@implementation Foo (ext)
- (void)woo {
// code code code
}
@end