NSNotificationCenter
来源:互联网 发布:数据库百度百科 编辑:程序博客网 时间:2024/05/22 03:14
NSNotificationCenter消息通信机制介绍(KVO)
作用: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];//获取到传递的对象
}
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSnotificationcenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- NSnotificationcenter
- NSNotificationCenter
- NSNotificationCenter
- NSNotificationCenter
- Android学习笔记 获取所点击View中的数据 更新adapter方法
- 《#诗盗#·鸳鸯溪》
- ASP.NET实现GridView删除功能
- UVA 10069 Distinct Subsequence
- LDA模型学习(代码)
- NSNotificationCenter
- ACdream 某群赛某题 Classification of the species
- 语言模型训练工具SRILM详解
- 状态模式
- Ubuntu 11.10 GCC4.5 GCC4.6无缝切换
- 工作习惯
- Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 问题的解决方法
- 安装qt5后编译运行后有关Qt at-spi的警告
- 契约优先方式编写wsdl + 隐式Header