xcode 在 NSKVODeallocateBreak 设置断点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7466652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting breakpoint at NSKVODeallocateBreak
提问by Crystal
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:
类 AddressAnnotation 的实例 0x1b7ac0 已被释放,而键值观察者仍向其注册。观察信息被泄露,甚至可能被错误地附加到其他物体上。在 NSKVODeallocateBreak 上设置断点以在调试器中停止。这是当前的观察信息:
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?
我不确定要设置断点的 NSKVODeallocateBreak 在哪里。我以为我可以使用 Instruments 来调试它,但是当我尝试时,它崩溃了,而没有给我任何关于它在哪里崩溃的指示。有什么想法吗?
回答by Fran Sevillano
You are probably doing something like this in your code:
你可能在你的代码中做这样的事情:
[addressAnnotation addObserver:self
forKeyPath:kSelectedAnnotationObserverKeyPath
options:NSKeyValueObservingOptionNew
context:@"selectedOrDeselected"];
[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];
[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 the Run
menu, Manage Breakpoints
, Add symbolic breakpoint
, enter NSKVODeallocateBreak
and there you are.
那应该消除错误。如果没有,并且您想调试它,您当然应该在 上设置断点NSKVODeallocateBreak
。为了做到这一点,打开Run
菜单,Manage Breakpoints
,Add symbolic breakpoint
,输入NSKVODeallocateBreak
你瞧。
Hope it helps!
希望能帮助到你!
回答by niklassaers
To set a breakpoint here with LLDB, start your app, then pause it, and at the LLDB debug prompt write:
要在此处使用 LLDB 设置断点,请启动您的应用程序,然后暂停它,并在 LLDB 调试提示处写入:
breakpoint set --name NSKVODeallocateBreak
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
现在你已经在那里设置了一个断点。希望这可以帮助您找到问题,这可能是@frowing 所描述的那种