NSNotificationCenter消息推送
来源:互联网 发布:库里季后赛数据 编辑:程序博客网 时间:2024/06/05 20:57
作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的.
注册通知:即要在什么地方接受消息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@" mytest" object:nil];
参数介绍:
addObserver: 观察者,即在什么地方接收通知;
selector: 收到通知后调用何种方法;
name: 通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
发送通知:调用观察者处的方法。
[[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray];
参数:
postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object:传递的参数
注册方法的写法:
- (void) mytest:(NSNotification*) notification
{
id obj = [notification object];//获取到传递的对象
}
0 0
- NSNotificationCenter消息推送
- NSNotificationCenter和消息推送的学习
- NSNotificationCenter消息机制
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息中心 NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- NSNotificationCenter 传递自定义消息
- NSNotificationCenter 处理自定义消息
- NSNotificationCenter消息机制
- IOS 消息机制(NSNotificationCenter)
- 消息中心NSNotificationCenter理解
- IOS 消息机制(NSNotificationCenter)
- 消息中心 NSNotificationCenter
- 消息中心 NSNotificationCenter
- 全自动遮罩层插件layer2.0版本发布(可传参),兼容IE7以上
- JS判断移动设备的终端类型(浏览器UserAgent)
- OpenCV for Ios 学习笔记(1)-配置
- 驱动开发(1)基础知识
- 输入输出之对象序列化Serializable
- NSNotificationCenter消息推送
- WebRTC知识分享——信令服务
- Linux下安装并使用Java开发opencv的配置
- 面试题 31
- Server 2008 使用总结
- Python3.5 右键没有Edit with IDLE选项
- .net micro framework 功能组件裁减
- 飞鸽传书源码分析-程序启动过程
- Android Gradle 基本模板