You are right, you need to call addObserver for all the view controllers you have, if you want all of them to receive the notifications. I created a small code piece to show you how it is done. I think you have all the answers you are asking for. Just try it out.
#import "ViewController.h"
@interface Employee:NSObject
@end
@implementation Employee
-(void)testMethod2:(NSNotification *)not{
NSLog(@"Test method2 is called");
}
@end
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)postNotifications:(id)sender {
Employee *employee = [[Employee alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testMethod:) name:@"Notification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testMethod1:) name:@"Notification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:employee selector:@selector(testMethod2:) name:@"Notification" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"Notification" object:nil];
}
-(void)testMethod:(NSNotification *)not{
NSLog(@"Test method is called");
}
-(void)testMethod1:(NSNotification *)not{
NSLog(@"Test method1 is called");
}
@end