Search code examples
iosandroid-mapviewmkannotationkey-value-observing

MapView, MKAnnotation & Key-Value-Observing - Error message


today I got an error with an explanation :) There's only one problem: I don't understand it :( So what am I doing wrong when I get this error?

2012-04-30 03:04:35.737 Barz[21961:11903] An instance 0x7491960 of class BarAnnotation 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:
    <NSKeyValueObservationInfo 0x74a18b0> (
    <NSKeyValueObservance 0x74a1700: Observer: 0x747f2b0, Key path: coordinate, Options: <New: NO, Old: NO, Prior: YES> Context: 0x0, Property: 0x74a11c0>
    )

Not that I did NOT add any observer manually, I just remove and add "BarAnnotation" (my custom MKAnnotation) to my mapView in the method viewWillAppear? I'm also not quite sure if I understood who is observing whom: Is my mapView observing all of the MKAnnotations? Or is my mapViewController (== mapView's delegate) observing? And why does it behave like that if I disabled dragging?

Hope someone can help me and answer some of these questions :)


Solution

  • I've seen this happen when the annotation's coordinates are invalid. Have you checked that?