传递数据NSNotification
来源:互联网 发布:试述关系数据库的特点 编辑:程序博客网 时间:2024/06/06 03:29
NSNotification 是一种在页面之间传递数据的方法,可以实现一对一和多对多的数据传递。
主要方法如下:
发送数据
//注册(第一步) NSNotification *notification =[NSNotification notificationWithName:@"mynotification" object:firstField.text]; //发送(第二步) [[NSNotificationCenter defaultCenter] postNotification:notification];
监听接收数据
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //接受端:接受(第一步) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:@"mynotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler2:) name:@"mynotification2" object:nil]; } //自定义接收信息和处理的方法(第二步) -(void) notificationHandler:(NSNotification *) notification{ secondField.text = [notification object];//收到消息后在UItextField中显示出来 }
监听必须在post之前,否则无效。
- 传递数据NSNotification
- (7)---01 iphone 开发 数据传递 NSNotification 通知机制演示
- IOS开发之利用通知(NSNotification)进行数据传递
- iOS开发-进阶:利用通知(NSNotification)进行数据传递
- NSNotification 传递参数
- 使用NSNotification传递参数
- [消息传递之一]-NSNotification练习
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- NSNotification
- cloudera安装hadoop集群和相关服务
- 有关树二叉树的一些操作
- 数据的离散化
- linux suse 超出频率限制 问题
- java编码(三)对InputStream和String有默认的编码
- 传递数据NSNotification
- listview android:cacheColorHint,android:listSelector属性作用
- ADS使用错误 could not open file debugrel \objectcode
- 获得当前鼠标的坐标
- 关于String 拼接字符串的性能问题
- 9.0.1.1.1修改8080端口,不是所有的牛奶都叫特仑苏,不是所有的orcl9i都叫9.2的
- C 语言的可变参数表函数的设计
- 第5天 结构体、文字显示与GDT/IDT初始化
- oracle中如何得到一条SQL语句的执行时间