سؤال

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?

هل كانت مفيدة؟

المحلول

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!

نصائح أخرى

To set a breakpoint here with LLDB, start your app, then pause it, and at the LLDB debug prompt write:

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top