I am attempting to send and receive messages through NSNotificationCenter
in Objective-C. However, I haven\'t been able to find any examples on how to do this.
This one helped me:
// Add an observer that will respond to loginComplete
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(showMainMenu:)
name:@"loginComplete" object:nil];
// Post a notification to loginComplete
[[NSNotificationCenter defaultCenter] postNotificationName:@"loginComplete" object:nil];
// the function specified in the same class where we defined the addObserver
- (void)showMainMenu:(NSNotification *)note {
NSLog(@"Received Notification - Someone seems to have logged in");
}
Source: http://www.smipple.net/snippet/Sounden/Simple%20NSNotificationCenter%20example