TableView not reloading from NSNotification

I'm having some trouble getting a tableView to reload using NSNotification.

My set up is that I have a filter view which allows the user to apply filters to the table view, once they click to change a filter I am sending an NSNotification which is picked up in the AppDelegate, this then reloads the core data applying the filters as a predicate.

Once the data has been loaded from core data I post another Notification to the tableView which tells it to reload it's data.

Using NSLog's I can see that the notifications are being sent and received although the [self.tableView reloadData] is doing nothing.

Here is my function to reload the data:

-(void)reloadTable:(NSNotification *)notification {
    NSLog(@"reloading table");
    [self.rootTableView reloadData];

Calling reload in the same way from inside the controller while it is currently in view works fine, so I'm pretty stuck as to why this isn't working.


Is the notification arriving on a thread other than the main thread? It would be if the notification were sent from a background thread. If this is the case, you'll need to marshall the reloadData call to the main thread. Something like this:

[tableView performSelectorOnMainThread: @"reloadData" withObject:nil waitUntilDone:NO];

This is for catching notification. You can put this in viewDidLoad.

NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center addObserverForName:kSFAccountsChanged object:nil 
                     queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
                             [tblView ReloadData];

The code below will fire a notification:

NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center postNotificationName:kSFAccountsChanged object:self];


Have you attached your table to rootTableView in interface builder?

Try adding

NSLog(@"%@", self.rootTableView);

This should not be null :)


If you have attached correctly, can you post the code in your table view delegate methods to see what's going on in there?

Need Your Help

Refresh with JPA connection

java jpa orm ejb-3.0

I'm using EJB3 and I have a problem related to refreshing my EntityManager.