When I try to run the code. my tableview does not show data. I think this is because the method cellforRowat indexpath does not get called.
but I am not sure why is is not getting called.
override func viewDidLoad() {
super.viewDidLoad()
getApiData()
leaderBoardTableView.delegate = self
leaderBoardTableView.dataSource = self
print(currentUser.userName)
self.tableView.backgroundColor = UIColor.black;
}
override func numberOfSections(in tableView: UITableView) -> Int {
number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("numofRoesInsec called")
return self.numRows
}
override func tableView(_ tableView: UITableView,
titleForHeaderInSection section: Int) -> String {
return "Leaderboard"
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("table view loading")
let cell = tableView.dequeueReusableCell(withIdentifier: "LeaderboardTableViewCell", for: indexPath) as! LeaderboardTableViewCell
cell.backgroundColor = UIColor.black
cell.name.textColor = UIColor.white
cell.rank.textColor = UIColor.white
cell.score.textColor = UIColor.white
cell.name.text = "\(self.data[indexPath.row]["username"])"
cell.score.text = "\(self.data[indexPath.row]["score"])"
cell.rank.text = "\(self.data[indexPath.row]["rank"])"
cell.name.textAlignment = .justified
cell.rank.textAlignment = .justified
cell.score.textAlignment = .justified
return cell
}
Selecting any option will automatically load the page