Nsnotificationcenter
The Notification Center provides a way to broadcast information within a program, and a Nsnotificationcenter object is essentially a notification sub-publication (Notification dispatch table).
Each running cocoa program has a default notification hub, which is generally not created by itself. A Nsnotificationcenter object can only deliver notifications in a separate program, and if you want to send and receive notifications in a different process, use an instance of Nsdistributednotificationcenter.
-(void) Addobserver: (ID) notificationobserver selector: (SEL) Notificationselector *) notificationname Object:(ID) notificationsender
Add a record to the recipient's sub-publication, followed by two optional parameters.
Notificationobserver as an observer, cannot be nil;
Notificationselector Sorry, the translation is not clear. When the receiver posts the notification, the observer executes the message specified by this parameter.
Notificationname the name of the notice used to register the Observer, that is, only a notification with that name is delivered to the observer. If you pass in nil, the Notification Center does not use the name of the notification to decide whether to post it to the observer.
Notificationsender popularly, is the observer who is willing to receive the notice. If you pass in nil, the notification Center does not need to notify sender to decide whether to post to the Observer (shit, true, is to receive all sender's notification, the third parameter is the same).
Note: Be sure to call the Dealloc before the viewerremoveObserver:name:object:来移除观察者。
-(void) Postnotification: (nsnotification *) notification
Post a given notification to the receiver. The parameter notification cannot be nil.
-(void) Postnotificationname: (NSString *) notificationname Object:(ID ) Notificationsender *) userInfo
Notificationsender the post notification object;
UserInfo the information about the notification, you can make nil.
Nsnotification
The Nsnotification object encapsulates information so that it can be broadcast to other objects by the Nsnotificationcenter object. A notification contains a name, an object, and an optional dictionary. A name is an identifier used to identify the notification. This object is a notification that the poster wants to send to the object that notifies the observer (in general, this is the object post for this notification). This dictionary stores any associated objects. The notification hub object is immutable.
Notification Center Nsnotificationcenter