Last active
December 5, 2019 15:18
-
-
Save riccjohn/7b27ae51f03a9275568e17b1e2de1632 to your computer and use it in GitHub Desktop.
RobotListViewController - Composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RobotListViewController: UIViewController { | |
@IBOutlet public var robotTableView: UITableView! | |
public let robotsDataSource = RobotListTableViewDataSource() | |
let robots: [Robot] = [ | |
Robot(id: 1, name: "Wooftot"), | |
Robot(id: 2, name: "Barkbot") | |
] | |
override public func viewDidLoad() { | |
super.viewDidLoad() | |
robotTableView.dataSource = robotsDataSource | |
} | |
public override func viewWillAppear() { | |
loadRobots() | |
} | |
func loadRobots() -> Void { | |
self.robotsDataSource.setRobots(robots) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment