hello all
I am building an app that tracks user location on map. I can insert a pin easily, but when the location is changed, the app quits.
I have set the default coordinates to 0,0 in viewdidload: method and I have added a pin at that location. I have done this because I want to remove the pin when location is updated and then insert the pin again on new location.
Here is the code which I have written in -(void)locationManager: didUpdateToLocation:fromLocation: method.
[mapview removeAnnotation:myannotation];
CLLocationCoordinate2D currentlocation;
currentlocation.latitude=newLocation.coordinate.latitude;
currentlocation.longitude=newLocation.coordinate.longitude;
myannotation=[[[CSMapAnnotation alloc]initWithCoordinate:currentlocation annotationType:CSMapAnnotationTypeStart title:@"My Location"] autorelease];
[mapview addAnnotation:myannotation];
Here, myannotation is the pin which I want to add,newLocation is the updated location and CSMapAnnotation will return annotation view.
The problem is my app crashes everytime. I was able to get warning message on console before crashing. Here is the message:
"An instance 0x182020 of class CSMapAnnotation 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."
So, plz help if anyone has faced the same problem...