cl.*_*cl. 3 xcode objective-c nsnotifications nsnotificationcenter ios
一个关于NSNotification......的快速问题如果我NSNotifications在一个方法中发布两个,并且它们被不同的对象观察到,选择器方法的执行顺序是什么?
例如,如果我有三个控制器 - 海报、接收器 A 和接收器 B。在海报控制器的功能中,我执行以下操作:
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReceiverADoSomething" object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReceiverBDoSomething" object:self];
Run Code Online (Sandbox Code Playgroud)
在接收者 A 的 viewDidLoad 方法中:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workToDoByA:) name:@"ReceiverADoSomething" object:nil];
Run Code Online (Sandbox Code Playgroud)
在接收者 B 的 viewDidLoad 方法中:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workToDoByB:) name:@"ReceiverADoSomething" object:nil];
Run Code Online (Sandbox Code Playgroud)
会先做workToDoByA再做workToDoByB吗?还是会一起被处决?
另一种情况......如果我有海报 A 发布通知,但有两个观察者到同一通知。那么执行顺序是什么?
在此先感谢您的帮助。
| 归档时间: |
|
| 查看次数: |
662 次 |
| 最近记录: |