NSNotificationCenter 编程简介
来源:互联网 发布:小米3qq健康 数据来源 编辑:程序博客网 时间:2024/05/01 15:30
1.注册通知:
即要在什么地方接受消息 (要注册接收通知的函数以及传递的对象,消息名称)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mytest:) name:@" mytest" object:nil];
参数介绍:
addObserver: 接收通知的观察者;
selector: 处理通知的函数;
name: 通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object: 封装到通知里的参数或者对象,可被接受者取出使用
2.处理通知的函数的示例:
- (void) mytest:(NSNotification*) notification
{
id obj = [notification object];//获取到传递的对象
}
3.发送通知:
发送名字为"xxx"的通知。
[[NSNotificationCenter defaultCenter] postNotificationName:@"mytest" object:searchFriendArray];
参数:
postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object:通知发送者发送通知时候携带参数或对象
0 0
- NSNotificationCenter 编程简介
- swift编程 NSNotificationCenter
- iOS开发-进阶: NSNotificationCenter 通知机制简介
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSnotificationcenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSnotificationcenter
- Solr主从配置
- Linux那些事儿 之 戏说USB(12)接口是设备的接口(一)
- java细节,你注意到了多少?
- android端调用服务端的webservice接口,报错总结。
- Android:自定义toast
- NSNotificationCenter 编程简介
- struct自然边界上的内存对齐
- 自行控制LoadRunner的socket协议性能测试
- JDK1.4读取word中的表格
- Xcode变更应用名称
- 获取tableviewCell在当前屏幕中的坐标值
- SQL - Using Cross Joins
- 无源最短路径之--地铁换乘
- Shell脚本常识--(条件判断)