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.
NSLog
within the controllers and see that order. On another note, I am curious for the answer to your other question about more than one observer to one notification. I have that scenario right now, and only one is firing, so I'd like to know as well... – Evert