Update tableview instantly as data pushed in core data iphone

Posted by user336685 on Stack Overflow See other posts from Stack Overflow or by user336685
Published on 2010-05-12T09:51:31Z Indexed on 2010/05/12 9:54 UTC
Read the original article Hit count: 297

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core