在哪里和如何注册接收通知的对象? [英] Where and how do I register an object for receiving a Notification?

查看:141
本文介绍了在哪里和如何注册接收通知的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当内存变低时,系统会发送 UIApplicationDidReceiveMemoryWarningNotification 通知。这就是苹果在这一点上的文章。但这个通知来自哪里,以及发送到哪个方法?

For example, when memory gets low, the System sends a UIApplicationDidReceiveMemoryWarningNotification notification. That's all Apple says in its docs at that point. But where does this notification come from, and to which method is it sent? Or where and how do I register what that I get notified?

推荐答案

它会发送到通知中心,其中所有通知集中。要通知此通知的对象通知哪个通知要通知哪个通知,以及在通知发出时应该调用哪个方法。

It is sent to the notification center, where all notifications are centralized. An object that wants to get informed about this notification registers itself to the notification center by telling which notification it wants to get informed and which method should be invoqued when the notification is raised.

有关详情,请参阅通知编程主题for Cocoa NSNotification类参考

这篇关于在哪里和如何注册接收通知的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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