I followed the dreammlax example, but I can't seem to get my NSNotification to work. Is there a framework or something I need to add? How do I debug the code.
FirstViewController posting
#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)btnSend:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"TestNotification"
object:self];
self.tabBarController.selectedIndex = 1;
}
@end
SecondViewController receiving
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveTestNotification:)
name:@"TestNotification"
object:nil];
//===Removed ===[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void) receiveTestNotification:(NSNotification *) notification
{
if ([[notification name] isEqualToString:@"TestNotification"])
NSLog (@"Successfully received the test notification!");
}
@end