From 522861e4346d4a6e7fa2a070398e415a6cbf1e16 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 20 Jan 2025 18:46:36 -0600 Subject: [PATCH] - refactored to use EmployeeTableViewCell Signed-off-by: Matt Bruce --- .../ViewControllers/EmployeesViewController.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EmployeeDirectory/ViewControllers/EmployeesViewController.swift b/EmployeeDirectory/ViewControllers/EmployeesViewController.swift index fe1fc3f..19018bc 100644 --- a/EmployeeDirectory/ViewControllers/EmployeesViewController.swift +++ b/EmployeeDirectory/ViewControllers/EmployeesViewController.swift @@ -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 } }