NSNotificationCenter: Do objects receive notifications on the same thread they are posted?

ⅰ亾dé卋堺 提交于 2019-11-30 08:15:22
Jarret Hardie

The short answer is yes... "Regular notification centers deliver notifications on the thread in which the notification was posted. Distributed notification centers deliver notifications on the main thread".

However, Apple has docs on this very subject that you may find helpful, and from which the above quote was pulled:

Notification Programming Topics: Delivering Notifications to Particular Threads

Just bothered to look it up myself, shameful:

From the class reference: NSNotificationCenter posts all notifications synchronously

Also, if you prefer, you can use NSNotificationQueue to post notifications asynchronously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!