0
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    [[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self]; //Add nearby buttons
}

In one UIViewController here is the sequence

  1. viewDidload get called
  2. [[NSNotificationCenter defaultCenter] postNotificationName:ListOrMapAddReloadButton object:self];

And because the notification set up is called at viewDidLoad, I kind of need viewDidLoad to be called first before `

  1. -(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

`

How could I achieve that?

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(addReloadButton) name:ListOrMapAddReloadButton object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(addNearbyButton) name:ListOrMapAddNearbyButton object:nil];
Girish
  • 4,692
  • 4
  • 35
  • 55
user4951
  • 32,206
  • 53
  • 172
  • 282

1 Answers1

2

Put your notifications in ViewWillAppear ()

Kasaname
  • 1,491
  • 11
  • 15
  • I want it to be called only once and then removed at dealloc. Hence I put it on viewdidload. I think viewdidload is a suitable "pair" for dealloc. – user4951 Mar 26 '13 at 04:55
  • 2
    Well actually the most suitable "pair" for `dealloc` would be `init`… – fumoboy007 Mar 26 '13 at 05:30