1. 程式人生 > >[iphone]NSNotificationCenter多執行緒的情況

[iphone]NSNotificationCenter多執行緒的情況

 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.

這句話是說,notification都是在post時的執行緒中被傳遞和接收,即使add observer時是在另外一個執行緒中。

例如: A, B兩個執行緒都addObserver。如果A中post,則無論此時B執行緒是否退出,回撥都在A中觸發,且觸發2次。