NSNotificationCenter通知中心
来源:互联网 发布:用visio画网络拓扑图 编辑:程序博客网 时间:2024/04/27 14:32
概述
NSNotificationCenter通知中心,通常用于一对一或者一对多的消息传递,即当一个地方改变时,要求改变其他的一些地方,例如当网络请求回来了新的数据,需要刷新本地信息和本地内存里面的界面时,当这些页面不只一个时就可以考虑使用通知中心
注册一个通知
代码实现
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector( ) name: object:nil];
发布通知中心事件
代码实现
NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:...];
[[NSNotificationCenter defaultCenter] postNotificationName: object:nil userInfo:dic];
注:dic为传给selector的参数
通知的响应事件
-(void)action:(NSNotification *)sender{
NSDictionary *dic = [sender userInfo];
}
从通知中心移除通知
[[NSNotificationCenter defaultCenter] removeObserver:self name: object:nil];
0 0
- 通知中心NSNotificationCenter
- 通知中心 NSNotificationCenter
- IOS NSNotificationCenter 通知中心
- 通知中心(NSNotificationCenter)
- NSNotificationCenter 通知中心
- 通知中心NSNotificationCenter
- NSNotificationCenter通知中心
- IOS NSNotificationCenter 通知中心
- NSNotificationCenter通知中心
- iOS通知中心(NSNotificationCenter)
- NSNotificationCenter(通知中心)
- 通知中心NSnotificationCenter
- iOS通知中心NSNotificationCenter
- 通知中心(NSNotificationCenter)
- 通知中心(NSNotificationCenter)
- NSNotificationCenter通知中心
- NSNotificationCenter通知中心
- 通知中心(NSNotificationCenter)
- [转]WaitForMultipleObject与MsgWaitForMultipleObjects用法
- 让你提升命令行效率的 Bash 快捷键
- RedHat 6.5 企业级下安装nginx,做负载均衡
- jdk7 新特性-Java语言的动态性-脚本语言支持api-使用案例06
- ASP:读取Excel并导入到access数据库中
- NSNotificationCenter通知中心
- <JAVA> 构造函数-->特权
- 利用Google Custom Search API抓取google搜索内容
- MFC多线程
- ViewPager实现滑动切换标签页
- 获取系统进程名时只出现进程名的首字母怎么解决?
- Photoshop脚本 > 同时创建多个选区
- ORA-00031-标记要终止的会话,在OS一级杀掉进程
- Fibonacci