- 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
|
||||
|
||||
// Configure TableView
|
||||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
||||
tableView.register(EmployeeTableViewCell.self, forCellReuseIdentifier: EmployeeTableViewCell.identifier)
|
||||
tableView.dataSource = self
|
||||
view.addSubview(tableView)
|
||||
tableView.frame = view.bounds
|
||||
@ -118,10 +118,11 @@ extension EmployeesViewController: UITableViewDataSource {
|
||||
}
|
||||
|
||||
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]
|
||||
cell.textLabel?.text = employee.fullName
|
||||
cell.detailTextLabel?.text = employee.emailAddress
|
||||
cell.configure(with: employee)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user