-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataSource.swift
63 lines (45 loc) · 1.97 KB
/
DataSource.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
62
63
//
// DataSource.swift
// Westeros
//
// Created by yisus on 18/07/2017.
// Copyright © 2017 yisus. All rights reserved.
//
import UIKit
final class DataSource {
static func houseDataSource (model: [House]) -> ArrayDataSource<House> {
return ArrayDataSource(model: model, cellMaker: {(house: House,tableView: UITableView) -> UITableViewCell in
let cellID = "House"
var cell = tableView.dequeueReusableCell(withIdentifier: cellID)
if cell == nil {
cell = UITableViewCell(style: .default, reuseIdentifier: cellID)
}
cell?.imageView?.image = house.sigil.image
cell?.textLabel?.text = house.name
cell?.detailTextLabel?.text = ""
return cell!
})
}
static func personDataSource (model: [Person]) -> ArrayDataSource<Person> {
return ArrayDataSource(model: model, cellMaker: {(person: Person,tableView: UITableView) -> UITableViewCell in
let cellID = "Person"
var cell = tableView.dequeueReusableCell(withIdentifier: cellID)
if cell == nil {
cell = UITableViewCell(style: .default, reuseIdentifier: cellID)
}
cell?.textLabel?.text = person.fullName
return cell!
})
}
static func seasonDataSource (model: [Season]) -> ArrayDataSource<Season> {
return ArrayDataSource(model: model, cellMaker: {(season: Season,tableView: UITableView) -> UITableViewCell in
let cellID = "Season"
var cell = tableView.dequeueReusableCell(withIdentifier: cellID)
if cell == nil {
cell = UITableViewCell(style: .default, reuseIdentifier: cellID)
}
cell?.textLabel?.text = season.title
return cell!
})
}
}