If I have several classes observing a particular NSNotification, in what order are the observers notified when the notification is posted?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
There is no guarantee as to what order notifications are sent out. If you need an ordering you may want to create a class that listens for one notification and sends out multiple ordered notifications that other classes can listen for instead.
I have tested it and it looks like the objects are ordered by addObserver method
Consol output for this test is :
AppDelegate.m
ViewController.m
The order is undefined. Apple manages a list of observers and whenever the notification is posted, they iterate over the list and notify every registered observer. The list may be an array or a dictionary or something completely different (e.g. a linked list of structs) and since observers can be added and removed at runtime at any time, the list may also change at any time, thus even if you knew how the list is currently implemented, you can never rely on any specific order. Further any OS X update may cause the list internals to change and what holds true for 10.7 may not hold true for 10.8 or 10.6.