在NSKVODeallocateBreak设置断点 [英] Setting breakpoint at NSKVODeallocateBreak

查看:367
本文介绍了在NSKVODeallocateBreak设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩地图工具包,我创建了一个注释。我试图找到由于此错误导致的错误:

I am playing around with the map kit and I created an annotation. I am trying to find my bug due to this error:


类名AddressAnnotation的实例0x1b7ac0已取消分配,而键值观察者仍在注册它。观察信息被泄露,甚至可能被错误地附加到其他物体上。在NSKVODeallocateBreak上设置断点以在调试器中停止。这是当前的观察信息:

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:

我不确定NSKVODeallocateBreak在哪里设置断点是。我以为我可以使用Instruments调试它,但是当我尝试时,它崩溃而没有给我任何指示它崩溃的地方。有什么想法?

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?

推荐答案

您可能在代码中做了类似的事情:

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];

这应该删除错误。如果没有并且您想要调试它,您当然应该在 NSKVODeallocateBreak 上设置断点。为此,请打开运行菜单,管理断点添加符号断点,输入 NSKVODeallocateBreak 就在那里。

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 the Run menu, Manage Breakpoints, Add symbolic breakpoint, enter NSKVODeallocateBreak and there you are.

希望有所帮助!

这篇关于在NSKVODeallocateBreak设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆