Skip to content

How to Fix iOS TableView Not Reloading Data

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Fix iOS TableView Not Reloading Data. We cover key concepts, practical examples, and best practices.

The Problem

You update the data array and call reloadData, but the table does not change:

items.append("New Item")
tableView.reloadData() // nothing happens

Or the table appears empty even though the data source has items.

Quick Fix

Step 1: Verify delegate and dataSource connections

In Interface Builder, the TableView's delegate and dataSource outlets must be connected to the ViewController. Or set them in code:

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.delegate = self
    tableView.dataSource = self
}

Step 2: Implement the required data source methods

extension ViewController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        cell.textLabel?.text = items[indexPath.row]
        return cell
    }
}

Missing numberOfRowsInSection or returning 0 causes an empty table.

Step 3: Call reloadData on the main thread

// Wrong - calling from background thread
DispatchQueue.global().async {
    self.items = fetchData()
    self.tableView.reloadData() // ignored
}

// Right
DispatchQueue.main.async {
    self.tableView.reloadData()
}

UIKit calls must happen on the main thread. Background-thread reloads are silently ignored.

Step 4: Register the cell identifier

// In viewDidLoad
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")

For storyboard prototypes, the identifier is set in Interface Builder. For code-created cells, register them explicitly.

Step 5: Check the cell reuse identifier

dequeueReusableCell(withIdentifier:) must match the identifier in Interface Builder or the registration. A mismatch returns nil or a cell of the wrong type.

Step 6: Update specific rows instead of the whole table

// Instead of reloadData, use:
tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .automatic)

This is more efficient and preserves scroll position.

Step 7: Check for estimated row height issues

tableView.estimatedRowHeight = 100
tableView.rowHeight = UITableView.automaticDimension

If estimated height is too small, the table may appear empty because all cells are below the visible area.

Prevention

  • Call reloadData on the main thread at all times.
  • Register all cell reuse identifiers in viewDidLoad.
  • Use diffableDataSource for automatic animated updates.

Common Mistakes with tableview reload

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world IOS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between reloadData and reloadRows?

reloadData refreshes the entire table. reloadRows refreshes specific index paths with animation. Use targeted reloads for better performance.

Why is my table empty even though the array has items?

The delegate/dataSource are not connected, the cell identifier is wrong, or numberOfRowsInSection returns 0. Check each one.

Can I call reloadData from a background thread?

No. All UIKit updates must occur on the main thread. Use DispatchQueue.main.async to ensure correct thread.

DodaTech Tool Reference

Doda Browser's UI Inspector can capture a live UITableView snapshot showing the current number of sections, rows, and visible cells for debugging data issues.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro