Swift - self.tableview.reloaddata() not working on Master Detail Application

273 views Asked by At

I used xcode's premade Master detail application and built off of that. For the tableview, I am making a json request and storing that into coredata; and trying to populate the table based on that coredata.

The way it works, is that the user logs in and then a request is made for a user's specific team. The resulting title and url are saved into coredata and used to populate the tableview/detail view.

Although the coredata is being updated (printing out the logs), the tableview itself is never being updated. I have tried putting self.tableView.reloadData() in viewDidLoad, viewDidAppear, and viewWillAppear; I have also tried creating a timer that calls the reloadData every .4 seconds (current code) and I never see the table cell's textLabel updated. However, if I tap on a cell, the link that is loaded in the detail view IS updated. So to re-iterate, the coredata is being updated, but the table never updates its label text.

If I stop running the app through xcode and then run it again, then the tableview is populated with the labels; but changing the team/user leads to the same results (the coredata/links are updated and the text labels are not)

My code is definitely not the cleanest/best, just trying to get it to work at the moment.

Here's my MasterViewController.swift: https://gist.github.com/aryanaziz/a9791a82061f156afdb9

EDIT: Found the issue. I was using the self.tableView.beginUpdates() function but was never using the self.tableView.endUpdates() which was causing problems. Removing the beginUpdates() had the tableview behaving like normal.

1

There are 1 answers

0
Aziz On

Found the issue. I was using the self.tableView.beginUpdates() function but was never using the self.tableView.endUpdates() which was causing problems. Removing the beginUpdates() had the tableview behaving like normal.