views:

183

answers:

1

Hi,

I'd like to reload a table view which is in another class called "WriteIt_MobileAppDelegate" from one of my other classes which is called "Properties". I've tried to do this via the NSNotificationCenter class - the log gets called but the table is never updated.

Properties.h:

 [[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged"
              object:[WriteIt_MobileAppDelegate class]
               userInfo:nil]; 

WriteIt_MobileAppDelegate.m

-(void)awakeFromNib {

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadItProperties:) name:@"NameChanged" object:self];

}

- (void) reloadItProperties: (NSNotification *)notification {

 NSLog(@"Reloading Data"); //this gets called
[[self navigationController] dismissModalViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
 [self.tblSimpleTable reloadData];
 [self.tblSimpleTable reloadSectionIndexTitles];
 // but the rest doesn't
}

What am I doing wrong here?

+2  A: 

Seems like you are using the object parameter wrong:

addObserver:selector:name:object:

notificationSender
The object whose notifications the observer wants to receive;
that is, only notifications sent by this sender are delivered to the observer. If you pass nil, the notification center doesn’t use a notification’s sender to decide whether to deliver it to the observer.

bddckr
i don't think so, [WriteIt_MobileAppDelegate class] is the only object that even toggles the NSLog. Is there another way of toggling the selector so that it updates the tableview?
David Schiefer