Does postNotification block until all observers complete?

The documentation (https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Notifications/Articles/NotificationQueues.html ) says:

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. 

Does this mean that each observer's handler must run to completion or are they dispatched asynchronously?
Traditionally they are run synchronously, that is, observers are run in the sequence on the thread that posted the notification.

Way back in the day (macOS 10.6!) we added -addObserverForName:object:queue:usingBlock: that allows an observer to run on a queue of their choice. That changes the rules somewhat. If an observer is installed this way, it will be queued before your post call returns but it won’t necessarily have run (indeed, it could be running concurrently on a different core).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Does postNotification block until all observers complete?
 
 
Q