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.
To expand upon dreamlax's example... If you want to send data along with the notification
In posting code:
NSDictionary *userInfo =
[NSDictionary dictionaryWithObject:myObject forKey:@"someKey"];
[[NSNotificationCenter defaultCenter] postNotificationName:
@"TestNotification" object:nil userInfo:userInfo];
In observing code:
- (void) receiveTestNotification:(NSNotification *) notification {
NSDictionary *userInfo = notification.userInfo;
MyObject *myObject = [userInfo objectForKey:@"someKey"];
}