I was getting the same error as you:
An instance 0xa975400 of class xxxxxx 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 the current observation info: <NSKeyValueObservationInfo 0xa980eb0> ( <NSKeyValueObservance 0xa980e70: Observer: 0xa94f8a0, Key path: coordinate, Options: <New: NO, Old: NO, Prior: YES> Context: 0x0, Property: 0xa980ef0>
As stated here, this was due to the fact that I was adding MKAnnotation with an invalid coordinate for MKMapView.
My solution was to create a function to check the actual coordinate.
Location + MKAnnotation.m
I created a category for my Place class and
#import "Place.h" #import <MapKit/MapKit.h> @interface Place (MKAnnotation) <MKAnnotation> - (BOOL)coordinateIsValid; ... @end
Location + MKAnnotation.m
@implementation Place (MKAnnotation) - (BOOL)coordinateIsValid { return CLLocationCoordinate2DIsValid(CLLocationCoordinate2DMake([self.latitude doubleValue],[self.longitude doubleValue])); } ... @end
I only add annotation to my ViewController if the coordinate is valid.
if([p coordinateIsValid]) { [self.mapView addAnnotation:p]; }
Sergio del amo
source share