-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeasonTableViewController.swift
61 lines (48 loc) · 1.81 KB
/
SeasonTableViewController.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
55
56
57
58
59
60
61
//
// SeasonTableViewController.swift
// Westeros
//
// Created by yisus on 30/08/2017.
// Copyright © 2017 yisus. All rights reserved.
//
import UIKit
class SeasonTableViewController: UITableViewController {
let model: [Season]
init(model: [Season]) {
self.model = model
super.init(nibName: nil, bundle: nil)
title = "Season"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellID = "SeasonCell"
// Descubrir cual es la casa que tenemos que mostrar
let season = model[indexPath.row]
// Crear una celda
var cell = tableView.dequeueReusableCell(withIdentifier: cellID)
if (cell == nil) {
// creamos a pelo
cell = UITableViewCell(style: .default, reuseIdentifier: cellID)
}
// sincronizar House -> Call
cell?.textLabel?.text = season.title
return cell!
}
// MARK: - Table view delegate
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let season = model[indexPath.row]
let houseVC = SeasonViewController(model: season)
navigationController?.pushViewController(houseVC, animated: true)
}
}