If a class registers for NSNotificationCenter
events of a certain type and another class posts an event of that type, will the code in the receiver execute before (synchronously) or after (asynchronously) the posting class continues?
- (void)poster {
[[NSNotificationCenter defaultCenter]
postNotificationWithName:@"myevent"
object:nil];
NSLog(@"Hello from poster");
}
- (void)receiver {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector:(mySelector)
name:@"myevent"
object:nil];
}
- (void) mySelector:(NSNotification *) notification {
NSLog(@"Hello from receiver");
}
In the code example above, will "Hello from receiver" be printed before or after "Hello from caller"?