-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEpisodeTableViewController.swift
55 lines (42 loc) · 1.51 KB
/
EpisodeTableViewController.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
//
// EpisodeTableViewController.swift
// Westeros
//
// Created by yisus on 30/08/2017.
// Copyright © 2017 yisus. All rights reserved.
//
import UIKit
class EpisodeTableViewController: UITableViewController {
let model: [Episode]
init(model: [Episode]) {
self.model = model
super.init(nibName: nil, bundle: nil)
title = "Episode"
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return model.count
}
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellID = "Episode"
// Descubrir cual es la casa que tenemos que mostrar
let episode = 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 = episode.title
return cell!
}
}