I've created a tableView with a registered Cell with reuseIdentifier as "cell". I've added this tableView to superview as subview.
private let tableView: UITableView = {
let table = UITableView()
table.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
return table
}()
I've comforted the protocol functions for TableViewCellDelegate and DataSource as below. But still when I do run the app it only shows my tableView but not the cells which should write "Hello". Why this might be happening?
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return notifications.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let model = notifications[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "Hello"
return cell
}
Do check with your notifications array is it empty or not if you are fetching it from api make sure to call tableView.reloadData()
have you added your tableView into view ?