iphone消息通信机制NSNotificationCenter
来源:互联网 发布:caliber中文软件 编辑:程序博客网 时间:2024/05/19 01:08
NSNotificationCenter是专门供程序中不同类间的消息通信而设置的,使用起来极为方便,
长话短说。
设置通知,就是说要在什么地方(哪个类)接受通知,一般在初始化中做。
[[NSNotificationCenter
我仅对以上参数做以说明:
addObserver 这个是观察者,就是说 在什么地方接收通知;
selector 这个是收到通知后,调用何种方法;
name: 这个是通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
发送通知,就是说此时要调用观察者处的方法。
[[NSNotificationCenter
我仅对以上参数做以说明:
postNotificationName:通知的名字,也是通知的唯一标示,编译器就通过这个找到通知的。
object:传递的参数
发送通知时,默认调用test方法。
- (void)
{
searchFriendArrary = [notification object];//通过这个获取到传递的对象
}
=========================================================
例::
=========================================================
@implementation chuanzhenAppDelegate
-(void) onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
//根据接收到的不同,来发送不同的消息。此处发送Login
[[NSNotificationCenter defaultCenter]postNotificationName:@"Login" object:self];
}
另一BeforeRootViewController.m里。
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(DidLogin) name:@"Login" object:nil];
}
-(IBAction) LoginClick
{
..............
}
- iphone消息通信机制NSNotificationCenter
- [iPhone开发]消息通信机制NSNotificationCenter
- iphone ios 消息通信机制NSNotificationCenter
- [iPhone开发]消息通信机制NSNotificationCenter
- iPhone开发之消息通信机制NSNotificationCenter
- iphone ios 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 详解iPhone开发之消息通信机制NSNotificationCenter
- NSNotificationCenter消息通信机制介绍
- 【IOS】消息通信机制NSNotificationCenter
- ios NSNotificationCenter消息通信机制
- NSNotificationCenter消息通信机制介绍(KVO)
- NSNotificationCenter消息通信机制介绍(KVO)
- 使用SQL Server维护计划实现数据库定时自动备份
- blog trackback test
- Android应用程序消息处理机制Handler分析
- MongoDB学习笔记(三) 在MVC模式下通过Jqgrid表格操作MongoDB数据
- VMware网络配置详解:三种网络模式简介及实现
- iphone消息通信机制NSNotificationCenter
- yii框架学习心得part1
- 在IHttpHandler中使用SESSION
- 幸福是一段旅程 ——艾佛烈德•德索萨
- 网店常用的商品属性选择功能(JQuery)
- 提高java代码运行效率(2)
- SQL Server 2008如何创建定期自动备份任务
- Ghost xp NetMeeting不能共享桌面的解决办法
- jsoup 简介