在我的一个 View Controller 中,它将自身添加为 UITextViewTextDidEndEditingNotification 通知的观察者,如下所示
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(done:) name:UITextViewTextDidEndEditingNotification object:nil];
现在我想知道 - 当 View Controller 被释放时我需要执行以下操作
[[NSNotificationCenter defaultCenter] removeObserver:self];
最佳答案
是的,当观察者被释放时,你应该总是删除它们。否则通知中心将保留对周围已释放对象的引用,并继续尝试将通知转发给它们。
关于iphone - dealloc 中是否需要removeObserver?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8665575/