[Solved] Refresh or reload data in function ViewWillAppear not always working in UITableViewcontroller


There are two things you should consider. First reload data will be called right away after reloadTransaction() if your url request hasn’t processed yet, it will show an empty tableView.

Second, when you have new data make sure to call the main thread before you call self.tableView.reloadData():

internal func reloadTransaction(){
    self.transactionList.removeAll()

    //get URL response and append data to transactinList
    ....
    //call self.tableView.reloadData() here after you append the new data

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

2

solved Refresh or reload data in function ViewWillAppear not always working in UITableViewcontroller