NSNotificationCenter发送通知
2014-05-25 17:26
169 查看
在开发过程中,我们常常会遇到需要在某一个视图中点击按钮,其它视图来响应该事件的情况。这时我们可以使用通知来完成这一过程。
[[NSNotificationCenter defaultCenter] postNotificationName:kReloadHomeCtrlNotification object:nil];
其中kReloadHomeCtrlNotification 一般是在预编译文件中宏定义的
同时要在另外一个地方来接收该通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(myAction) name:kReloadHomeCtrlNotification object:nil];
其中myAction即是在接收到该通知时响应的事件,只需要将name,即kReloadHomeCtrlNotification 与之前发送通知的name相对应,就可以发送接收通知了
[[NSNotificationCenter defaultCenter] postNotificationName:kReloadHomeCtrlNotification object:nil];
其中kReloadHomeCtrlNotification 一般是在预编译文件中宏定义的
同时要在另外一个地方来接收该通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(myAction) name:kReloadHomeCtrlNotification object:nil];
其中myAction即是在接收到该通知时响应的事件,只需要将name,即kReloadHomeCtrlNotification 与之前发送通知的name相对应,就可以发送接收通知了
相关文章推荐
- Windows消息(二):消息的分类以及模拟发送控件通知消息
- 详解Windows消息分类以及WM_COMMAND与WM_NOTIFY的区别,以及模拟发送控件通知消息
- kettle定时任务_第三方合作方有订单自动发送邮件通知_20161214
- 从一个线程中给另一个线程发送通知
- 发送已创建用户电子邮件通知
- 招商银行信用卡重要通知:消费提醒服务调整,300元以下消费不再逐笔发送短信
- Event Handler的开发与部署--扩展练习:上传文档后,指定用户,添加发送邮件通知操作
- QT线程发送消息通知界面小例
- 基于netfilter通过iptables过滤http请求使用netlink通知用户空间构造发送http响应(一)
- iOS应用崩溃日志分析低内存闪退 因为低内存崩溃日志与普通崩溃日志略有不同,所以本教程特别分开说明一下。 iOS设备检测到低内存时,虚拟内存系统发出通知请求应用释放内存。这些通知发送到所有正在运行
- iOS8.0+ 第三方输入法多次发送UIKeyboard相关的通知
- Java play freamwork 新闻通知的定时发送
- 基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (4): 配置传出邮件服务: 使用 outlook.com 发送邮件通知
- PHP 命令行模式实战之cli+mysql 模拟队列批量发送邮件(在Linux环境下PHP 异步执行脚本发送事件通知消息实际案例)
- 通过第三方接口发送短信验证码/短信通知(推荐)
- python3 自动获取公网ip并发送邮件通知
- 【广告项目】钉钉实现发送通知
- Windows SVN变更发送邮件通知(JAVA实现)
- Android JPush (通讯录好友,是该应用app,则发送一条提示消息,点击通知,跳进对应的页面)
- 网站发送短信的工具类,验证码、通知消息等