Update tableview instantly as data pushed in core data iphone
- by user336685
I need to update the tableview as soon as the content is pushed in core data database.
for this
AppDelegate.m contains following code
NSManagedObjectContext *moc = [self managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"FeedItem" inManagedObjectContext:moc]];
//for loop
// push data in code data & then save context
[moc save:&error];
ZAssert(error == nil, @"Error saving context: %@", [error localizedDescription]);
//for loop ends
This code triggers following code from RootviewController.m
- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller
{
[[self tableView] beginUpdates];
}
But this updates the tableview only at the end of the for loop ,the table does not get updated after immediate push in db.
I tried following code but that didn't work
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
// In the simplest, most efficient, case, reload the table view.
[self.tableView reloadData];
}
I have been stuck with this problem for several days.Please help.Thanks in advance for solution.