-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathCellConfigurator.swift
More file actions
41 lines (31 loc) · 955 Bytes
/
CellConfigurator.swift
File metadata and controls
41 lines (31 loc) · 955 Bytes
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
//
// CellConfigurator.swift
// ConfigurableTableViewController
//
// Created by Arkadiusz Holko on 03-01-16.
// Copyright © 2016 Arkadiusz Holko. All rights reserved.
//
import UIKit
struct SectionConfigurator {
var cellConfigurators: [CellConfiguratorType]
init(cellConfigurators: [CellConfiguratorType]) {
self.cellConfigurators = cellConfigurators
}
}
protocol CellConfiguratorType {
var reuseIdentifier: String { get }
var cellClass: AnyClass { get }
func updateCell(cell: UITableViewCell)
}
struct CellConfigurator<Cell where Cell: Updatable, Cell: UITableViewCell> {
let viewData: Cell.ViewData
let reuseIdentifier: String = NSStringFromClass(Cell)
let cellClass: AnyClass = Cell.self
func updateCell(cell: UITableViewCell) {
if let cell = cell as? Cell {
cell.updateWithViewData(viewData)
}
}
}
extension CellConfigurator: CellConfiguratorType {
}