Nsnotification
Recently do exercise project found in a UIView without controller puch to Uiviewcontroller, need to use the notification value
The notification value is a one-to-many value-transfer method;
Notification hubs can pass values across multiple pages, usually from a later page to the previous page. Idea: The value of the third interface is passed to the first interface. 1. In the first interface to establish a notification center, through the Notification Center, register a listener event 2. In the first interface, set up events to receive notifications. 3. In the first interface in the Dealloc, remove the notification center, be sure to remove the notification, otherwise it will cause memory leaks; 4. In the required interface, establish a notification center, through the Notification center, send notifications (the process of sending notifications is the process of transmitting value, the value to be transferred as the value of object to the first interface code: in the first interface
// Add a dictionary to Pass the value of the label through the key value setting
nsdictionary *dict =[[nsdictionary alloc] initwithobjectsandkeys: [nsstring stringWithFormat:@ "%d", (int) abtn. Tag],@ "Abtn.tag", Nil];
// Create a notification
nsnotification *notification =[nsnotification notificationwithname:@ "Puch" Object:nil userInfo:d ICT];
// send notifications via notification hubs
[[nsnotificationcenter defaultcenter] postnotification: notification];
To remove a notification:
[[Nsnotificationcenter Defaultcenter] removeobserver:observer name:nil object:self];
On the required interface:
// registration Notice
[[nsnotificationcenter defaultcenter] addobserver:self selector:@ Selector(Tongzhi:) name:@ "Puch" object:nil];
-(void) Tongzhi: (nsnotification *) puch{
NSLog(@ "%@", Puch. UserInfo[@ "Abtn.tag"]);
NSLog(@ "toreceive notification ------");}
Http://www.cnblogs.com/lmyailgs/p/4460791.html
nsnotification--Notification Pass Value