NSNotificationCenter Is Not Thread-safe
In fact, if your app has multiple threads, then you’re almost certainly using
NSNotificationCenter
wrong.[…]
The above code crashes reliably in the
NSLog
aftersleep
. Why? What we see here is thatremoveObserver:
does not block until all notifications have been posted. The method can return while a notification is still executing on another thread. Thus, we have a race condition.