- refactored to use EmployeeTableViewCell
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
09c8a1ef5a
commit
522861e434
@ -27,7 +27,7 @@ class EmployeesViewController: UIViewController {
|
|||||||
view.backgroundColor = .white
|
view.backgroundColor = .white
|
||||||
|
|
||||||
// Configure TableView
|
// Configure TableView
|
||||||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
tableView.register(EmployeeTableViewCell.self, forCellReuseIdentifier: EmployeeTableViewCell.identifier)
|
||||||
tableView.dataSource = self
|
tableView.dataSource = self
|
||||||
view.addSubview(tableView)
|
view.addSubview(tableView)
|
||||||
tableView.frame = view.bounds
|
tableView.frame = view.bounds
|
||||||
@ -118,10 +118,11 @@ extension EmployeesViewController: UITableViewDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: EmployeeTableViewCell.identifier, for: indexPath) as? EmployeeTableViewCell else {
|
||||||
|
return UITableViewCell()
|
||||||
|
}
|
||||||
let employee = viewModel.employees[indexPath.row]
|
let employee = viewModel.employees[indexPath.row]
|
||||||
cell.textLabel?.text = employee.fullName
|
cell.configure(with: employee)
|
||||||
cell.detailTextLabel?.text = employee.emailAddress
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user