i'm using core data in my app, but i notice that is a bit slow and i have some crash of problems of inconsistency, maybe i have bad managed it, however i want pass to SQLite
and i found the FMDB
library, but my question is how i can automatically update a tableview when i made background change in the database? using the core data there is the NSFetchedController
and in particular there is the NSFetchedResultsControllerDelegate
to automatic refresh the table view, how i can perform this using the SQLite?
You can use NSNotificationCenter
for that, Here is the code sample..
In your TableViewController.m file add this code
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self) {
// Custom initialization
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTableView:) name:@"ReloadTableView" object:nil];
}
return self;
}
- (void)reloadTableView:(NSNotification*)notification
{
[tableView relodData];
}
And where you call your background thread, put this code in its completion.
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadTableView" object:nil];