Http://blog.csdn.net/kaizi318/article/details/8294127
Each process has a default nsicationicationcenter. You can use the defacenter center class method to obtain the instances of this message center. The message center can process messages between different objects in the same process. If you want to communicate between processes on the same machine, you need to use nsdistributednotificationcenter.
The message center distributes messages synchronously to all the observers. In other words, the control is returned to the caller after all the observers receive the messages and process the messages.
1 // Step 1: Implement callback function 2-(void) callback 3 {4 nslog (@ "Callback method called"); 5} 6 7 // Step 2: registering a notification with the notification center indicates the notifications that self is interested in, when the notification center receives this notification, it will notify the current object. // is the name used as the unique identifier for the notification? 9 [[nsicationicationcenter defacenter center] addobserver: self10 selector: @ selector (callback) 11 name: @ "God-level notification" 12 object: Nil]; 13 14 // remember to cancel registration when appropriate
15 [[nsicationicationcenter defacenter center] removeobserver: Self name: @ "God-level notification" Object: Nil]; 16 17 // Step 3: send a notification to the notification center anywhere in the same thread. Nsnotification is the 18 [[nsnotificationcenter defacenter center] postnotificationname: @ "God-level notification" Object: Nil] of synchronous blocking.