A quick question about NSNotification
... If I post two NSNotifications
in a method, and they are observed by different objects, what is the sequence of execution of the selector method?
For instance, if I have three controllers - Poster, Receiver A and Receiver B. In a function of the Poster controller, I do the following:
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReceiverADoSomething" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReceiverBDoSomething" object:self];
In the viewDidLoad method for receiver A:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workToDoByA:) name:@"ReceiverADoSomething" object:nil];
In the viewDidLoad method for receiver B:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workToDoByB:) name:@"ReceiverADoSomething" object:nil];
Will workToDoByA
be done first followed by workToDoByB
?
Or they will be executed together?
Another scenario... If I have Poster A posting a notification but there are two observers to the SAME notification. What is the execution sequence then?
Thanks in advance for your help.
A excerpt from Apple docs:
the same policy is for postNotificationName.