如果我愿意
[[NSNotificationCenter defaultCenter] postNotificationName:@"N" object:self];
NSLog(@"here");
在执行NSLog(@"here");
之前,会同步通知观察者...如果所有对象都在同一个线程上,是否保证同步执行(立即)?
找不到明确说明的内容
最佳答案
是的,虽然埋得很好:
Using the NSNotificationCenter’s postNotification: method and its variants, you can post a notification to a notification center. However, the invocation of the method is synchronous: before the posting object can resume its thread of execution, it must wait until the notification center dispatches the notification to all observers and returns.
来源:
关于ios - postNotificationName 是否保证立即发送给监听者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38944228/