I use NSFetchedResultsControllerDelegate to display my cells after all my datas are downloaded and inserted into coreData.
I use the code below to know when a modification occurred
[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshDatas:) name:NSManagedObjectContextDidSaveNotification object:nil];
then, this method is called
- (void)refreshDatas:(NSNotification *)notification
{
[[self.fetchedResultsController managedObjectContext] mergeChangesFromContextDidSaveNotification:notification];
}
But, i have a problem, there is 5 to 10 seconds between the first call of insertRowAtIndexPath of the delegate NSFetchedResultsControllerDelegate and the display of the cell inserted in the UITableView and i don’t know why.
Thanks for your help
If you are using a background thread and the notification is fired there, you need to “republish” the notification in the main thread like:
If this it is not the problem, try to add some details to your question. Core Data is difficult and without details it’s difficult to understand what is going on.
Edit
You don’t merge changes if the
[notification object](a context in this case) is the main one. On the contrary, if that context is coming from a different thread, you merge changes. This is for performance reasons but you could simply remove it.Hope that helps.