NSNotificationCenter通知,用userInfo实现
2016-01-12 17:07
330 查看
1、发通知
NSDictionary *myDictionary = [NSDictionary dictionaryWithObject:@”sendValue” forKey:@”sendKey”];
//这里是一个dic格式数据,可以放入各种数据
2、接受通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noticeMethod:) name:@”myNotice” object:nil];
3、调用方法,接受信息。
- (void)noticeMethod:(NSNotification *)notification
{
//在这里可以得到想要的数据
NSString *getsendValue = [[notification userInfo] valueForKey:@”sendKey”];
}
NSDictionary *myDictionary = [NSDictionary dictionaryWithObject:@”sendValue” forKey:@”sendKey”];
//这里是一个dic格式数据,可以放入各种数据
[[NSNotificationCenter defaultCenter] postNotificationName:@"myNotice" object:nil userInfo:myDictionary];
2、接受通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noticeMethod:) name:@”myNotice” object:nil];
3、调用方法,接受信息。
- (void)noticeMethod:(NSNotification *)notification
{
//在这里可以得到想要的数据
NSString *getsendValue = [[notification userInfo] valueForKey:@”sendKey”];
}
相关文章推荐
- 理解Spark的核心RDD
- 自定义Adpter使用方法以及注意点
- JS组件系列——Bootstrap 树控件使用经验分享
- Windows Server 2012 Hyper-V群集
- linux PS1环境变量使用
- .Net读取AD中的用户并使用BootstrapTable的ajax分页
- IOS界面弹窗显示多个按钮
- oracle 11g GRID 中 关于 OLR 需要知道的一些内容
- stat函数的用法
- mysql中Access denied for user 'root'@'localhost' (using password:YES)的解决办法(本人实操)
- Linux下软件安装和卸载
- DIY:利用Arduino制作智能家居系统
- 多媒体格式
- 坦克大战游戏步骤 思路 与代码(一)
- Android网络图片加载框架:Universal-ImageLoader简介
- C3P0 相关配置描述
- lightoj 1214 大数的整除
- windows下使用TortoiseGit代替Git命令行操作
- Swift开发IOS-UIActionSheet
- 查找olr备份路径