-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeasonViewController.swift
54 lines (41 loc) · 1.36 KB
/
SeasonViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// SeasonViewController.swift
// Westeros
//
// Created by yisus on 30/08/2017.
// Copyright © 2017 yisus. All rights reserved.
//
import UIKit
class SeasonViewController: UIViewController {
@IBOutlet weak var lbTitle: UILabel!
@IBOutlet weak var lbDate: UILabel!
let model: Season
init(model: Season) {
self.model = model
super.init(nibName: nil, bundle: nil)
self.title = model.title
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func syncViewWithModel () {
lbTitle.text = model.title
lbDate.text = model.date.description
}
func setUpUi () {
let episodes = UIBarButtonItem(title: "Episodes",
style: .plain,
target: self,
action: #selector(displayEpisodes))
navigationItem.rightBarButtonItem = episodes
}
@objc func displayEpisodes () {
let episodesVC = EpisodeTableViewController(model: model.sortedEpisodes())
navigationController?.pushViewController(episodesVC, animated: true)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setUpUi()
syncViewWithModel()
}
}