So, I am just testing NSNotifications on a variety of cases and this one is confusing. I would appreciate it if you could help me understand NSNotifications !
I have a N
The differences you are describing seem to be due to changes in which objects are alive when. Views and view controllers do not exist indefinitely, and are not all created when the app starts. An object has to exist to receive and log a notification. The basic notification system is working as expected.
You should be able to see the effect of lifetime on the messages received if you add log statements announcing when an object that is supposed to receive one of these notifications is created and when it is destroyed within the body of -init
(or whatever the designated initializer of your superclass is) and -dealloc
.
Also: Your log statements will be easier to track down if you tag them with the function doing the logging like NSLog(@"%s:
. The compiler generates a string named __func__
for each function that contains the function's name.