Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我经常在 viewDidLoad 中注册 NSNotification 并在 dealloc 中取消注册。我们在 ios 5 中没有 dealloc。我将在哪里取消注册 NSNotification?
你仍然可以在 ARC 中使用 dealloc(我假设这就是你所说的 iOS 5)——只需像以前一样定义方法。只是不要调用 [super dealloc]。
- (void) dealloc { // unregister and clean up. // NO SUPER! }
我经常使用这种模式——尤其是在检查泄漏时,将 NSLog 放在那里很方便。