【发布时间】:2014-10-03 16:46:16
【问题描述】:
- 典型故事...从一年前离职的程序员那里继承了一个有缺陷的应用程序。
- 应用使用了一些时髦的过渡插件;即 iCarousel、MPFFlipTransition。
- 应用会弹出单独的浏览器标签。
- 关闭浏览器或浏览器选项卡时引发错误
- 观察者在某处被泄露。
-
我已将以下代码添加到相关类中,但没有成功:
- (无效)dealloc { //实现dealloc方法/删除 [[NSNotificationCenter defaultCenter] removeObserver:self]; }
如何跟踪应用程序以找到设置此观察者的位置?我可以观察特定的内存位置吗?我可以以某种方式查看键/值对吗?谢谢,基思
抛出错误:
2014-10-03 12:33:20.938 myApp[5299:60b] An instance 0x145661f0 of class DesktopBrowserVC was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x14547300> (
<NSKeyValueObservance 0x14547210: Observer: 0x145550a0, Key path: title, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x14547320>
【问题讨论】:
-
KVO 与 NSNotificationCenter 是分开的。您是否在代码中看到添加了 KVO 观察者但没有后续
removeObserver调用(在 dealloc 或诸如此类)的任何地方?
标签: ios xcode key-value key-value-observing dealloc