Skip to content

Commit

Permalink
Move VC setup code into init where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottwilliams committed Jun 5, 2017
1 parent 3ce70fe commit f07d619
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
8 changes: 3 additions & 5 deletions Proper/Controllers/POIMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,20 @@ class POIMapViewController: UIViewController, ProperViewController {
self.isUserLocation = isUserLocation
self.connection = connection
super.init(nibName: nil, bundle: nil)

map.delegate = self
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Lifecycle

override func loadView() {
view = MKMapView()
view.translatesAutoresizingMaskIntoConstraints = false
}

override func viewDidLoad() {
map.delegate = self
}
// MARK: Lifecycle

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand Down
23 changes: 8 additions & 15 deletions Proper/Controllers/POITableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ class POITableViewController: UITableViewController, ProperViewController {
self.stations = stations
self.mapPoint = mapPoint
super.init(style: style)

tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.dataSource = dataSource
tableView.register(UINib(nibName: "ArrivalTableViewCell", bundle: nil),
forCellReuseIdentifier: "arrivalCell")
tableView.register(UINib(nibName: "POIStationHeaderFooterView", bundle: nil),
forHeaderFooterViewReuseIdentifier: "stationHeader")
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
Expand Down Expand Up @@ -89,15 +96,6 @@ class POITableViewController: UITableViewController, ProperViewController {

// MARK: Lifecycle

override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = dataSource
tableView.register(UINib(nibName: "ArrivalTableViewCell", bundle: nil),
forCellReuseIdentifier: "arrivalCell")
tableView.register(UINib(nibName: "POIStationHeaderFooterView", bundle: nil),
forHeaderFooterViewReuseIdentifier: "stationHeader")
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

Expand All @@ -114,11 +112,6 @@ class POITableViewController: UITableViewController, ProperViewController {
super.viewDidDisappear(animated)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// MARK: Table View Delegate
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return POIViewModel.arrivalRowHeight
Expand Down

0 comments on commit f07d619

Please sign in to comment.