NSNotification
来源:互联网 发布:数据备份还原系统 编辑:程序博客网 时间:2024/05/22 06:04
NSNotification
(2012-07-05 14:50:53)不同类关联事件通知,
如:类A发生某事件然后通知类B,类B获取通知,然后采取某行动,
发送方:
作成通知:
NSNotification *
cn = [NSNotification notificationWithName:@"
Today"
object:self];
通知开始执行:
[[NSNotificationCenter defaultCenter] postNotification:
cn];
收信方:
取得通知:
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
去通知中心要求得到通知同时呼叫需执行的方法:
[nc addObserver:self selector:@selector(hello)
name: @"Today"
object:nil];
-(void)hello{
//处理
}
发送方:
作成要传送的值:
NSDictionary *dic = [NSDictionary dictionaryWithObject:@"HOGE"
forKey:@"KEY" ];
作成通知:
NSNotification *n = [NSNotification notificationWithName:@"Today"
object:self
userInfo:dic];
通知开始执行:
[[NSNotificationCenter defaultCenter] postNotification:
cn];
收信方:
取得通知:
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
去通知中心要求得到通知同时呼叫需执行的方法:
[nc addObserver:self selector:@selector(hello :)
name:@"Today"
object: nil];
-(void)
hello:(NSNotificationCenter*)center{
//从通知得到的值 center
NSString *value = [[center userInfo] objectForKey:@"KEY"];
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification example
- NSNotification详解
- 通知 NSNotification
- NSNotification 译注
- Linux 让PHP支持MSSQL [linux]
- Linux常用的一些内核参数(调优)
- ubuntu更新源
- vb通用过程简介
- Android 应用打包签名
- NSNotification
- eclipse_classic_插件
- 设置系统默认输入法为
- AndroidManifest.xml配置文件详解
- GLES20Canvas.java:424 java.lang.UnsupportedOperationException
- android中流媒体
- 后排版式自适应调整图片大小(js)
- wget ftp密码特殊字符
- win32下boost::asio进一步封装