Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. protocol WithView {
  2. var insideView: UIView! { get }
  3. }
  4.  
  5. class Controller1: UIViewController, WithView {
  6.  
  7. var insideView: UIView!
  8.  
  9. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  10. insideView.touchesBegan(touches, with: event)
  11. }
  12.  
  13. /* Functionality of Controller 1 */
  14. }
  15.  
  16. class Controller2: UIViewController, WithView {
  17.  
  18. var insideView: UIView!
  19.  
  20. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  21. insideView.touchesBegan(touches, with: event)
  22. }
  23.  
  24. /* Functionality of Controller 2 */
  25. }
  26.  
  27. protocol WithView {
  28. var insideView: UIView! { get }
  29. }
  30.  
  31. extension UIViewController where Self: WithView {
  32. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  33. insideView.touchesBegan(touches, with: event)
  34. }
  35. }
  36.  
  37. class Controller1: UIViewController, WithView {
  38.  
  39. var insideView: UIView!
  40.  
  41. /* Functionality of Controller 1 */
  42. }
  43.  
  44. class Controller2: UIViewController, WithView {
  45.  
  46. var insideView: UIView!
  47.  
  48. /* Functionality of Controller 2 */
  49. }
  50.  
  51. extension WithView where Self: UIViewController {
  52. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  53. insideView.touchesBegan(touches, with: event)
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement