Notes for iOS notifications and notes for iOS notifications

Source: Internet
Author: User
Tags notification center

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 ************ ************

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.