Notes for iOS notifications and notes for iOS notifications
The value transfer function of iOS notifications for highly coupled interfaces is convenient and convenient.
On the View Controller that needs to be implemented in the modal pop-up mode, a view controller can be used to navigate. Add the navigation view Controller naVC. view of this view controller to the view Controller presentedVC. view in the modal pop-up mode.
How can I pass the value on the second-level view Controller on naVC to presentedVC?
Solution: use notification
1. Create a notification on the naVC second-level view Controller Interface for value passing
// Create a notification NSNotification * notification = [NSNotification notificationWithName: @ "sendSelectTitle" object: nil userInfo :@{@ "key": value}];
2. Send a notification through the notification center
// Send a notification through the notification center [[NSNotificationCenter defacenter center] postNotification: notification];
3. register the observer and bind the execution method of this notification through the notification center in viewDidLoad that needs to receive the page worth presentedVC
// Register the notification [[NSNotificationCenter defacenter center] addObserver: self selector: @ selector (make :) name: @ "sendSelectTitle" object: nil];
4. If the registered object does not need to receive information, cancel the token in the notification (when the presentedVC mode disappears)
[Self dismissViewControllerAnimated: NO completion: ^ {// logout notification [[nsicationicationcenter defacenter center] removeObserver: self name: @ "sendSelectTitle" object: nil];}];
* ****************** System notifications do not need to be sent through the notification center ************ ************