Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # Shared code that exists in framework
  2.  
  3. ```
  4. @objc public protocol Sound {
  5. @objc optional func woo()
  6. }
  7.  
  8. public class Foo: NSObject, Sound {
  9. func action() {
  10. ((self as Sound).woo ?? default_woo)() // calls `woo` method if available or defaults to default_woo method
  11. }
  12.  
  13. func default_woo() {
  14. // called if class Foo does not implement `woo` somewhere
  15. }
  16. }
  17. ```
  18.  
  19. # Code that exists in client (aka App Target)
  20.  
  21. ### swift
  22. ```
  23. extension Foo {
  24. func woo() {
  25. // code code code
  26. }
  27. }
  28. ```
  29.  
  30. ### objc
  31. ```
  32. @implementation Foo (ext)
  33.  
  34. - (void)woo {
  35. // code code code
  36. }
  37.  
  38. @end
  39. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement