Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Shared code that exists in framework
- ```
- @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
- }
- }
- ```
- # Code that exists in client (aka App Target)
- ### swift
- ```
- extension Foo {
- func woo() {
- // code code code
- }
- }
- ```
- ### objc
- ```
- @implementation Foo (ext)
- - (void)woo {
- // code code code
- }
- @end
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement