|
| 1 | +import UIKit |
| 2 | + |
| 3 | +print("Optional protocol methods") |
| 4 | +//protocol Route { |
| 5 | +// func moveToHomeScreen() |
| 6 | +// func moveToSettings() |
| 7 | +//} |
| 8 | +// |
| 9 | +//class IntroViewController: Route { |
| 10 | +// func moveToHomeScreen() { |
| 11 | +// // implementation |
| 12 | +// } |
| 13 | +// |
| 14 | +// func moveToSettings() { |
| 15 | +// // implementation |
| 16 | +// } |
| 17 | +//} |
| 18 | +// |
| 19 | +//class HomeViewController: Route { |
| 20 | +// // not required in this case |
| 21 | +// func moveToHomeScreen() { |
| 22 | +// // implementation |
| 23 | +// } |
| 24 | +// |
| 25 | +// func moveToSettings() { |
| 26 | +// // implementation |
| 27 | +// } |
| 28 | +//} |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +//protocol Route { |
| 36 | +// func moveToHomeScreen() |
| 37 | +// func moveToSettings() |
| 38 | +//} |
| 39 | +// |
| 40 | +//extension Route { |
| 41 | +// func moveToHomeScreen() { |
| 42 | +// // implementation |
| 43 | +// } |
| 44 | +//} |
| 45 | +// |
| 46 | +//class IntroViewController: Route { |
| 47 | +// func moveToHomeScreen() { |
| 48 | +// // implementation |
| 49 | +// } |
| 50 | +// |
| 51 | +// func moveToSettings() { |
| 52 | +// // implementation |
| 53 | +// } |
| 54 | +//} |
| 55 | +// |
| 56 | +//class HomeViewController: Route { |
| 57 | +// // not required in this case |
| 58 | +// func moveToHomeScreen() { |
| 59 | +// // implementation |
| 60 | +// } |
| 61 | +// |
| 62 | +// func moveToSettings() { |
| 63 | +// // implementation |
| 64 | +// } |
| 65 | +//} |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +//@objc protocol Route { |
| 72 | +// @objc optional func moveToHomeScreen() |
| 73 | +// func moveToSettings() |
| 74 | +//} |
| 75 | +// |
| 76 | +//class IntroViewController: Route { |
| 77 | +// func moveToHomeScreen() { |
| 78 | +// // implementation |
| 79 | +// } |
| 80 | +// |
| 81 | +// func moveToSettings() { |
| 82 | +// // implementation |
| 83 | +// } |
| 84 | +//} |
| 85 | +// |
| 86 | +//class HomeViewController: Route { |
| 87 | +// func moveToSettings() { |
| 88 | +// // implementation |
| 89 | +// } |
| 90 | +//} |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +protocol HomeRoute { |
| 96 | + func moveToHomeScreen() |
| 97 | +} |
| 98 | + |
| 99 | +protocol SettingsRoute { |
| 100 | + func moveToSettings() |
| 101 | +} |
| 102 | + |
| 103 | +class IntroViewController: HomeRoute, SettingsRoute { |
| 104 | + func moveToHomeScreen() { |
| 105 | + // implementation |
| 106 | + } |
| 107 | + |
| 108 | + func moveToSettings() { |
| 109 | + // implementation |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +class HomeViewController: SettingsRoute { |
| 114 | + func moveToSettings() { |
| 115 | + // implementation |
| 116 | + } |
| 117 | +} |
0 commit comments