I have a grouped UITableView where not all sections may be displayed at once, the table is driven by some data that not every record may have. My trouble is that the record
I solved the issue by setting tableView's dataSource and delegate where I initialize the tableView.
Note: remember you might need to make tableView lazy to assign when initializing the tableView.
lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.separatorStyle = .none
tableView.backgroundColor = .white
tableView.dataSource = self
tableView.delegate = self
return tableView
}()