Nsnotificationcenter can achieve a greater span of communication mechanisms than Delegate, which can communicate with two non-referencing two objects. The Nsnotificationcenter communication principle uses the observer pattern;
1. Nsnotificationcenter registered observers are interested in an event (named after a string) and the Selector or Block that is executed when the event is triggered
2. Nsnotificationcenter the event at a certain time (named by string)
3. The observer performs the corresponding Selector or Block when receiving an event of interest
To use notification hubs:
1. Registered Observer
[[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (selector) name:@ " notification_name" object: nil";
2. Triggering events (publishing broadcasts)
[[Nsnotificationcenter Defaultcenter] Postnotificationname:@ "notification_name" Object: nil];
3. The selector method is automatically executed by the Observer
4. Cancel the listener when you do not want to listen (be sure to do it while the object is destroyed)
generally unregister before the listener is destroyed (such as by adding the following code to the listener):-(void) dealloc { [[Nsnotificationcenter Defaultcenter] Removeobserver:self];}