I have a tab bar controller with two views. When i press a button in my second view, i send a notification to my first view and i want my first view to reload its data. But if i switch over to my first view from my second view, the first view data hasn’t been reloaded. I’m using AQGridview, btw.
//firstView.m
-(void) reloadGridView: (NSNotification *)notification
{
[_gridView reloadData];
}
- (void)viewDidLoad
{
//notification for added exercise
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadGridView:) name:@"reloadGridView" object:nil];
}
//secondView.m
- (IBAction)AddExercise:(id)sender
{
[[NSNotificationCenter defaultCenter] postNotificationName: @"reloadGridView" object: nil];
}
It’s probably better to call the reloadData from the viewDidAppear in the first tab rather than using notifications.