Reputation: 605
I have a view controller with two table views in it and all their data comes from a single object. The second table view has a TextView in it that I can use to change the model object. When I enter text in the TextView, the top TableView (without the text field) updates, but not the bottom.
After Edits:
Minimum Code Reproduction: Github Repo
Upvotes: 0
Views: 78
Reputation: 77690
Tough to say what exactly is causing the problem, but it seems to be a timing issue.
In ViewController
, change your didSet
to this:
var timecard: Timecard? {didSet {
if self.isViewLoaded {
DispatchQueue.main.async {
self.employeeTableView.reloadData()
self.timecardTableView.reloadData()
}
}
}}
In your minimal example, that seems to fix the issue.
Without spending a lot more time on it, my guess would be that you've got a closure that's holding onto the cell being edited, preventing the table view from reloading? Maybe something similar to that.
On a side note -- you've got some rather unusual stuff going on. Generally a bad idea to assign things like this:
weak var viewController: ViewController?
And, it looks like your closures could be problematic in a couple ways (row index can change, looks like you're creating strong references that can cause retain cycles, etc).
Upvotes: 1