I am using a custom map annotation class for map view in iPhone. Whenever I pop my map view from navigation bar stack I usually see some warnings in console.
MapAnnotation 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 am not using KVO in my code hence not able to understand why I am receiving these warnings
Latitude and Longitude have differing bounds:
Passing a value outside of those bounds will cause the custom class to be deallocated and therefore giving you the error that you're receiving. Make sure that you are passing the correct values for both Latitude and Longitude.
It would be really nice if Apple passed a bounding error for this instead of an early release error. That would've saved me roughly 5 hours worth of time
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's 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 pointed here it was caused because I was adding a MKAnnotation with an invalid coordinate to a MKMapView.
My solution was to create a function to check the coordinate valid.
Place+MKAnnotation.m
I created a category of my Place class and
#import "Place.h"
#import <MapKit/MapKit.h>
@interface Place (MKAnnotation) <MKAnnotation>
- (BOOL)coordinateIsValid;
...
@end
Place+MKAnnotation.m
@implementation Place (MKAnnotation)
- (BOOL)coordinateIsValid
{
return CLLocationCoordinate2DIsValid(CLLocationCoordinate2DMake([self.latitude doubleValue],[self.longitude doubleValue]));
}
...
@end
I only add the annotation in my ViewController if the coordinate is valid.
if([p coordinateIsValid]) {
[self.mapView addAnnotation:p];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With