Differences between nsnotification and delegate

Source: Internet
Author: User

The difference between nsnotification and delegate is briefly described.:


1.EfficiencyIt must be that the delegate is higher than nsnotification.


2. The delegate method is more direct than notification. The most typical feature is that,The delegate method usually needs to focus on the returned values.That is, the result of the delegate method. For example,-windowshouldclose: whether yes or no is returned. Therefore, the delegate method usually contains the word "shocould", which is a very expressive word. That is, if you do my delegate, I will ask you if you want to close the window? You need to give me an answer. I will decide how to proceed based on your answer. On the contrary,The biggest characteristic of notification is that it does not care about the attitude of the recipient., I just release the announcement. If you accept it or not, it is your business. At the same time, I don't care about the result. Therefore, notification often uses the did term, such as nswindowdidresizenotification. After the nswindow object releases the notification, nothing will happen and it will not wait for the recipient's response.

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.