Skip to content

Commit b270ce6

Browse files
committed
Split out protocol conformance to an extension
1 parent 44b7388 commit b270ce6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

RotatingWheelController/ViewController.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
import os
1010
import UIKit
1111

12-
class ViewController: UIViewController, SMRotaryProtocol {
12+
class ViewController: UIViewController {
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
let wheel = SMRotaryWheel(frame: view.frame, delegate: self, numberOfSections: 3)
16+
view.addSubview(wheel)
17+
}
18+
}
19+
20+
extension ViewController : SMRotaryProtocol {
1321
func viewFor(tag: Int) -> UIView {
1422
let view = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
1523
view.backgroundColor = .red
@@ -21,13 +29,5 @@ class ViewController: UIViewController, SMRotaryProtocol {
2129
func wheelDidChangeValue(to: Int) {
2230
os_log(OSLogType.default, "%d", to);
2331
}
24-
25-
override func viewDidLoad() {
26-
super.viewDidLoad()
27-
let wheel = SMRotaryWheel(frame: view.frame, delegate: self, numberOfSections: 3)
28-
view.addSubview(wheel)
29-
}
30-
31-
3232
}
3333

SMRotaryProtocol.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
import UIKit
1010

1111
protocol SMRotaryProtocol {
12-
func wheelDidChangeValue(to: Int)
1312
func viewFor(tag: Int) -> UIView
13+
func wheelDidChangeValue(to: Int)
1414
}

0 commit comments

Comments
 (0)