1 removeObserver不要忘记调用了,否则Observer对象被释放后是会Crash的.
2 postNotification是同步的,也就是A 在postNotification 之后需要等到B 接收到Notification
3 接收消息的回调函数是和postNotification在同一个线程的,和addObserver以及removeObserver在哪个线程无关
APPLE官方文档相关内容以及链接:
A notification center delivers notifications to observers synchronously. In other words, when posting a notification, control does not return to the poster until all observers have received and processed the notification. To send notifications asynchronously use a notification queue, which is described in Notification Queues.
In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself.
来源于:
以上.