ios – Swift – Tableview reloads only after second tap of the tab bar


I’ve read 3 pages of google results and none worked for me, here’s detailed description of the problem:

Every time I launch my app If I tap on the tab bar item that shows the vc that contains my table view it is empty. I have to go to another tab and return to it, just then my table view fetches. Spent 8h trying to fix it already.

Same exact VC shown with a button tap is displayed correctly and loads every time.

What i’ve already tried:

  • triple checked if I have:
    tableView.delegate = self
    tableView.dataSource = self
  • Tried moving the fetching to viewDidAppear or viewWillAppear, none worked.
  • Diagnosed it, number of sections is returned but number of rows = 0, cellForRowAt never executes on first tab bar click, even tho my posts are fetched correctly.
  • Tried fixing any constraints that exist, didn’t work.

It simply seems like tableView.reloadData() doesn’t work. I surrender, please help me!