NSNotificationCenter 发送消息先后问题
来源:互联网 发布:多比软件jain 编辑:程序博客网 时间:2024/06/06 15:52
今天测试了NSNotificationCenter发送消息后,在目标函数和调用函数中,功能执行顺序:
代码如下:
- (void)begin
{
}
- (void)buttonClicked:(id)sender
{
}
-(void)viewDidLoad
{
}
- (void)viewDidUnload
{
}
发现打印的顺序为:
2012-08-03 14:00:56.239 testNotifyBegin[6522:f803]notify:0
2012-08-03 14:00:56.607 testNotifyBegin[6522:f803] notify:1
2012-08-03 14:00:56.960 testNotifyBegin[6522:f803] notify:2
2012-08-03 14:00:57.283 testNotifyBegin[6522:f803] notify:3
。
。
。
2012-08-03 14:00:57.283 testNotifyBegin[6522:f803] notify:98
2012-08-03 14:00:57.283 testNotifyBegin[6522:f803] notify:99
然后才是
2012-08-03 14:11:56.089 testNotifyBegin[6522:f803] main:0
2012-08-03 14:12:00.338 testNotifyBegin[6522:f803] main:1
2012-08-03 14:12:05.220 testNotifyBegin[6522:f803] main:2
2012-08-03 14:12:06.368 testNotifyBegin[6522:f803] main:3
2012-08-03 14:12:07.077 testNotifyBegin[6522:f803] main:4
。
。
。
2012-08-03 14:12:06.368 testNotifyBegin[6522:f803] main:98
2012-08-03 14:12:07.077 testNotifyBegin[6522:f803] main:99
所以说,NSNotificationCenter在post消息后,会一直调用函数中会一直等待被调用函数执行完全,然后返回控制权到主函数中,再接着执行后面的功能。即:这是一个同步阻塞的操作。
如果要想不等待,直接返回控制权,可以采用NSNotificationQueue。
具体参考:
http://www.cnblogs.com/xiaouisme/archive/2012/04/06/2434753.html
- NSNotificationCenter 发送消息先后问题
- 通过NSNotificationCenter发送通知
- NSNotificationCenter发送通知
- NSNotificationCenter 发送 接受处理
- NSNotificationCenter消息机制
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息中心 NSNotificationCenter
- 消息通信机制NSNotificationCenter
- 消息通信机制NSNotificationCenter
- NSNotificationCenter 传递自定义消息
- NSNotificationCenter 处理自定义消息
- NSNotificationCenter消息机制
- IOS 消息机制(NSNotificationCenter)
- 消息中心NSNotificationCenter理解
- IOS 消息机制(NSNotificationCenter)
- java后台面试相关知识总结(1)
- Ubuntu下搭建JavaEE开发环境
- 坐标系中直线所围成的阴影面积
- sizeof & strlen
- POJ3169 Layout 差分约束
- NSNotificationCenter 发送消息先后问题
- 给SEO新手的四条“忠告”
- 《算法概论》第一次作业之编程
- iptable使用心得
- 可穿戴设备提供数据未必全可信
- 新的一天新的开始 给力
- android中画虚线--.PathEffect类简单认识
- Twitter网站短暂宕机约30分钟
- html基础学习