在 NSKVODallocateBreak 设置断点
我正在使用地图套件并创建了一个注释。由于此错误,我正在尝试查找我的错误:
类 AddressAnnotation 的实例 0x1b7ac0 已被释放,而键值观察者仍向其注册。观察信息被泄露,甚至可能被错误地附加到其他物体上。在 NSKVODallocateBreak 上设置断点以在调试器中停止。以下是当前的观测信息:
我不确定要设置断点的 NSKVODallocateBreak 在哪里。我以为我可以使用 Instruments 来调试它,但是当我尝试时,它崩溃了,并且没有给我任何崩溃位置的指示。有什么想法吗?
I am playing around with the map kit and I created an annotation. I am trying to find my bug due to this error:
An instance 0x1b7ac0 of class AddressAnnotation 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:
I'm not sure where that NSKVODeallocateBreak to set a breakpoint at is. I thought I could use Instruments to debug it, but when I try, it crashes without giving me any indication to where it crashed. Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能在代码中执行类似的操作:
[addressAnnotation addObserver:self
forKeyPath:kSelectedAnnotationObserverKeyPath
选项:NSKeyValueObservingOptionNew
context:@"selectedOrDeselected"];
这意味着您正在注册一个观察者来查找注释何时被选择。
当注释从地图中删除时,您应该删除观察者,如下所示:
[addressAnnotation removeObserver:self forKeyPath:kSelectedAnnotationObserverKeyPath];
这应该会消除错误。如果没有,并且您想调试它,那么您当然应该在
NSKVODeallocateBreak
上设置断点。为此,请打开运行
菜单,管理断点
,添加符号断点
,输入NSKVODallocateBreak
,然后你是。希望有帮助!
You are probably doing something like this in your code:
[addressAnnotation addObserver:self
forKeyPath:kSelectedAnnotationObserverKeyPath
options:NSKeyValueObservingOptionNew
context:@"selectedOrDeselected"];
That means that you are registering an observer to find out when an annotation has been selected.
You should remove the observer when the annotation gets removed from the map, like this:
[addressAnnotation removeObserver:self forKeyPath:kSelectedAnnotationObserverKeyPath];
That should remove the error. If it doesn't and you want to debug it, you certainly should set a breakpoint on
NSKVODeallocateBreak
. In order to do this, open theRun
menu,Manage Breakpoints
,Add symbolic breakpoint
, enterNSKVODeallocateBreak
and there you are.Hope it helps!
要使用 LLDB 在此处设置断点,请启动应用程序,然后暂停它,并在 LLDB 调试提示符处写入:
现在您已在那里设置了断点。希望这可以帮助您找到问题,这可能是@frowing 所描述的类型
To set a breakpoint here with LLDB, start your app, then pause it, and at the LLDB debug prompt write:
Now you've got a breakpoint set there. Hopefully this should help you find the problem, which probably will be of the kind described by @frowing