iOS通知如何传值?
2015-12-23 17:46
363 查看
ViewController *viewVC = [[ViewController
alloc]
init];
[[NSNotificationCenter
defaultCenter] addObserver:viewVC
selector:@selector(sendVaue:)
name:@"showmessage"
object:nil];
NSDictionary *dict = [[NSDictionary
alloc] initWithObjectsAndKeys:@"user",@"type",
nil];
[[NSNotificationCenter
defaultCenter] postNotificationName:@"showmessage"
object:dict];
[self.navigationController
pushViewController:viewVC animated:YES];
在ViewController.m 接收值
-(void)sendVaue:(NSNotification *)notification{
id message = [notification
object];
NSLog(@"sendVaue
- message: %@",message);
}
alloc]
init];
[[NSNotificationCenter
defaultCenter] addObserver:viewVC
selector:@selector(sendVaue:)
name:@"showmessage"
object:nil];
NSDictionary *dict = [[NSDictionary
alloc] initWithObjectsAndKeys:@"user",@"type",
nil];
[[NSNotificationCenter
defaultCenter] postNotificationName:@"showmessage"
object:dict];
[self.navigationController
pushViewController:viewVC animated:YES];
在ViewController.m 接收值
-(void)sendVaue:(NSNotification *)notification{
id message = [notification
object];
NSLog(@"sendVaue
- message: %@",message);
}
相关文章推荐
- iOS中Block介绍(二)内存管理与其他特性
- iOS透明viewControler
- iOS 添加PCH全局引用文件 —— HERO博客
- iOS开源库
- IOS button图片与文字互换
- ios 手势操作举例
- iOS -- 图形绘制(全)
- iOS开发系统版本适配(未完待续。。。)
- iOS - 归档的理解和摘记
- iOS如何获取设备声音和振动功能
- iOS CGContextRef画图小结
- ios——学习网址收集
- ios发布可能出现的问题
- iOS如何获取设备硬件信息
- iOS的绘图机制
- iOS字符串的大小写互相转换
- iOS如何从一个界面返回到指定界面?
- iOS CoreAnimation专题——原理篇(三) CALayer的模型层与展示层
- iOS中强制转换
- iOS中消息的传递机制