Skip to content

Instantly share code, notes, and snippets.

@riccjohn
Last active December 5, 2019 15:18
Show Gist options
  • Save riccjohn/7b27ae51f03a9275568e17b1e2de1632 to your computer and use it in GitHub Desktop.
Save riccjohn/7b27ae51f03a9275568e17b1e2de1632 to your computer and use it in GitHub Desktop.
RobotListViewController - Composition
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