我发现NSNotificationCenter在ARC中使用时,即使你忘记删除了observerfrom defaultCenter和observerhas deallocated,然后你发布了观察者观察到的通知,也没有崩溃了!
在Xcode 4之前,没有ARC,我们必须observer在dealloc功能中删除默认通知中心,如下所示:
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Run Code Online (Sandbox Code Playgroud)
否则当发布绑定通知时,它会发生崩溃!
所以,问题是如何在NSNotificationCenter检测解除了分配observer的ARC ?