gpt4 book ai didi

ios - postNotificationName 是否保证立即发送给监听者?

转载 作者:行者123 更新时间:2023-12-02 02:29:35 25 4
gpt4 key购买 nike

如果我愿意

[[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.

来源:

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Notifications/Articles/NotificationQueues.html

关于ios - postNotificationName 是否保证立即发送给监听者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38944228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com