Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

iphone - Setting breakpoint at 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:

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Hope it helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...