I have the following code in my
Code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
//Other Code
[newAnnotation addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:@"ANSELECTED"];
//Other Code
}
And I use the KVO to see when it is selected or not.
However when I then call
Code:
[mapView removeAnnotations:existingpoints];
I get a KVO error and can't work out the code to remove the observer. Any ideas on the code to remove it as the bit here doesn't work
Code:
An instance 0x3b13e0 of class MKAnnotationView is being deallocated while key value observers are still registered with it. Observation info is being 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:
<NSKeyValueObservance 0x3afde0: Observer: 0x31dc20, Key path: selected, Options: <New: YES, Old: NO, Prior: NO> Context: 0x10f984, Property: 0x3afcf0>
Current removal code....
Code:
for (id annotation in mapView.annotations) {
[self removeObserver:annotation forKeyPath:@"selected"];
}