Nsnotificationcenter the application of the scene, the principle of mechanism, the use of steps.
Order of use of notification hubs: first make sure that the Observer is registered, because sending notifications is instantaneous, and if there are no registered observers, then registration is not received until the notification is sent.
Summary: Notifications are only sent to the currently listening object.
Code
Registration Notifications Register for monitoring on the page that cares about the notification
[[nsnotificationcenter defaultcenter] addobserver:self selector:@ Selector(Tongzhi:) name:@ "Tongzhi" object:nil];
Send notifications Make sure you have registered to listen to the notification.
Nsdictionary *dict =@{@ "key":@ "Value"};
// Create a notification
nsnotification *notification =[nsnotification notificationwithname:@ "Tongzhi" Object:nil userInfo:d ICT];
// send notifications via notification hubs
[[nsnotificationcenter defaultcenter] postnotification: notification];
Method of callback after receiving notification
-(void) Tongzhi: (nsnotification *) text{
NSLog(@ "%@", text. UserInfo[@ "key"]);
NSLog(@ "--receive notification ------");
}
Be sure to remove the listener when you don't need to receive notifications
[[Nsnotificationcenter Defaultcenter] removeobserver:self];
Http://www.wtoutiao.com/a/1385824.html This is a good summary.
Pending summary ...
IOS Notification Center Nsnotificationcenter detailed