Notification is commonly used in the jump controller between the proxy method, in addition to proxy mode, notification is more convenient, convenient, a simple demo implementation of the notification of the jump value.
Enter the information you want to send, passing the value of the label through the button method call.
-(Ibaction) ButtonClick: (ID) Sender {
Add a dictionary to pass the value of the label through the key value setting
Nsdictionary *dict =[[nsdictionary alloc]initwithobjectsandkeys:self.textfieldone.text,@ "TextOne", self.textfieldtwo.text,@ "Texttwo", nil];
Create a notification
Nsnotification *notification =[nsnotification notificationwithname:@ "Tongzhi" object:niluserInfo:dict];
Send notifications via notification hubs
[[Nsnotificationcenter Defaultcenter] postnotification:notification];
[Self.navigationcontroller Popviewcontrolleranimated:yes];
}
After sending the notification, register the notification listener in the controller you want to receive, and send the message to receive
-(void) Viewdidload {
[Super Viewdidload];
Registration Notice
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (Tongzhi:) name:@ "Tongzhi" object:nil];
}
-(void) Tongzhi: (nsnotification *) text{
NSLog (@ "%@", text.userinfo[@ "Textone"]);
NSLog (@ "--Receive notification------");
}
Removal notifications: Removeobserver: and RemoveObserver:name:object:
Where Removeobserver: is the DELETE Notification Center saves the schedule table for all the portals of an observer, and RemoveObserver:name:object: is to delete a portal that matches the observer in the dispatch table saved by the notification center.
This is relatively straightforward, just call the method on the line. For example:
[[Nsnotificationcenter Defaultcenter] removeobserver:observer name:nil object:self];
Note that the parameter notificationobserver is the observer to be deleted and must not be nil.
Use of iOS notification pass-through values