iPhone-NSNotification的目的是什么? [英] iphone - What is the purpose of NSNotification?

查看:118
本文介绍了iPhone-NSNotification的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 能请您解释什么是 NSNotification的目的,以及 我可以使用哪些情况 它吗?

  1. Can you please explain what is the purpose of the NSNotification, and what are some situations I could use it?

是否通知所有班级的学生 在应用程序中,还是将其称为 特定类别,通过 代表?

Does a notification call all classes in the app, or does it call a specific class, by passing a delegate?

是否可以创建1 通知,并在 多个班级?

Is it possible to create 1 notification, and receive it on multiple classes?

推荐答案

  1. 使用NSNotification可以将多个事件通知给多个对象,而不必关心哪个对象以及其中有多少个对象正在监听该通知.

  1. Using NSNotification you can notify multiple objects about some event and you can do that not caring about which objects and how many of them are listening for that notification.

NSNotification通过NSNotificationCenter对象,该对象负责从创建它们的对象(使用postNotification:函数族)获取通知,并将其发送到已注册的对象以侦听特定的通知(接收通知对象必须注册)在NSNotificationCenter中使用addObserver:函数)

NSNotification passes through NSNotificationCenter object that is responsible for getting notifications from objects who create them (using postNotification: functions family) and sending them to the objects who are registered to listen to specific notification (to receive notification object must register in NSNotificationCenter using addObserver: functions)

通知可以被多个对象观察到-所有对象都必须在NSNotificationCenter中注册,

Notification can be observed by multiple objects - all of them must just register in NSNotificationCenter,

这篇关于iPhone-NSNotification的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆