Trying to refresh a TableView after FileSharing in AppDelegate
I have an app that has 3 different Storyboard Views with TableViews and Controllers. The Views are accessed through a TabBar Controller. The TableViews load data and present data from a Core Data store.
In my AppDelegate, I have added code that opens files with extensions my app recognizes. The code adds the contents of the files to a Core Data database.
I'm using AlertViews to ask the user if they would like to save the data.
All this is working quite well.
The problem I have is that when my app "becomes active" my initial TabBar View is presented and it presents a tableview of the data in the core database in it's original state. Then my AppDelegate file sharing code kicks in to read the file and add the data to the database ... but ...
... my initial View is not updated after the AlertView "Save" button is pushed and the data is updated to the Core Database. The AlertView message disappears and leaves the original view presented in its original state.
I've tried "reload" in various spots in the View's Controller ... nothing. I've tried switching tabs from the AppDelegate ... that kinda works but ...
I really want the View to update after the AlertView disappears and control returns to the View Controller.
thanks in advance!!
I believe you should be using a NSFetchedResultsController attached to the UITableViewController as it detects changes in the ManagedObjectContext (i.e. saves) and correctly updates the tableview. More info: NSFetchedResultsController