I use NSNotificationfor a specific set of events. I have three views such that I have the “ADD” button in view 1 and a click, which makes me move from view 1 to view 2, to view 3 and return to view 1 again.
1-> 2-> 3-> 1
I use NSNotificationto press the view controller if the ADD button on view 1 is pressed, and I update other views accordingly based on the notification sent by View 1.
When a notification is sent from view 1, only view 2 receives it. View 3 is not.
How is this possible? The code for observers is EXACTLY the same in view 2 and view 3.
This is the code to add observers to view 2 and view 3:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didPressAdd:)
name:@"DidAddNotification"
object:nil];
I also delete them in the function dealloc()correctly.
source
share