0

I'm doing an IOS App with a MKMapView I use a navigation controller in order to go from the main menu to the mapview and from the mapview with a back button to the main menu again. This works ok!. But if I drop some annotations on the map and press the back button, the app crashed every time.

In the debug navigator of xcode there is error about: lldb_unnamed_function1128$$CoreLocation

Also some info from Crashlytics:

0
CoreLocation    
CLClientCreateIso6709Notation + 31645
1
libobjc.A.dylib 
objc_object::sidetable_release(bool) + 174
2
libobjc.A.dylib 
objc_object::sidetable_release(bool) + 174
3
MapKit  
std::__1::__vector_base<objc_object* __strong, std::__1::allocator<objc_object* __strong> >::~__vector_base() + 28
4
MapKit  
MKQuadTrieNodeFree(MKQuadTrieNode*) + 32
5
MapKit  
__38-[MKQuadTrie clearAllItemsPerforming:]_block_invoke + 72
6
MapKit  
_breadthFirstApply(MKQuadTrieNode*, MKQuadTrieTraversalDirective ()(MKQuadTrieNode*) block_pointer) + 186
7
MapKit  
-[MKQuadTrie clearAllItemsPerforming:] + 166

What is lldb_unnamed_function1128$$CoreLocation error

Can anyone help? :)

My back button code:

- (IBAction)backPressed:(id)sender {
    [self.mapView removeAnnotations:self.mapView.annotations];
    [self.mapView removeOverlays:self.mapView.overlays];
    self.locationManager.delegate = nil;
    self.mapView.delegate = nil;
     NSLog(@"Done!");
}

viewForAnnotation code:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

    if (annotation == mapView.userLocation) {
        return nil; // Let map view handle user location annotation
    }

    // Identifyer for reusing annotationviews
    static NSString *annotationIdentifier = @"icon_annotation";

    // Check in queue if there is an annotation view we already can use, else create a new one
    IconAnnotationView *annotationView = (IconAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
    if (!annotationView) {
        annotationView = [[IconAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
        annotationView.canShowCallout = YES;
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    }

    return annotationView;

}

the code that add the annotations (named reload button):

- (IBAction)reload:(id)sender {


    [self.mapView removeOverlays:self.mapView.overlays];

    if (!userPressedReload) {

        self.parkPlace1 = [[Place alloc] initWithLong:40.975301  Lat:22.069451 iconStatus:[NSNumber numberWithInt:2] beforeMin:[NSNumber numberWithInt:10]];
        self.parkPlace2 = [[Place alloc] initWithLong:40.981507 Lat:22.057485 iconStatus:[NSNumber numberWithInt:1] beforeMin:[NSNumber numberWithInt:20]];
        [self.mapView addAnnotation:self.parkPlace1];
        [self.mapView addAnnotation:self.parkPlace2];

        userPressedReload = YES;
    }

      self.annotations = [NSMutableArray arrayWithArray:self.mapView.annotations];
    if (self.mapView.userLocation) {
        [self.annotations removeObject:self.mapView.userLocation];
    }

    [self.mapView removeAnnotations:self.annotations];
    [self.mapView addAnnotations:self.annotations];

}
  • It would be helpful if you posted the code you're using to add the annotation and the back button action (if it's not standard) – Gad Feb 19 '14 at 08:14
  • did you add the `CoreLocation` framework ? – GoGreen Feb 19 '14 at 08:37
  • Yes i added! The app works, the problem is when I go back to the main menu – Anestis Tsoulfas Feb 19 '14 at 09:01
  • can you post the code related to before _"But if I drop some annotations"_ – GoGreen Feb 19 '14 at 09:07
  • and also try adding an [exception breakpoint](http://stackoverflow.com/questions/17802662/exception-breakpoint-in-xcode) to your project to diagnose the error. – GoGreen Feb 19 '14 at 09:10
  • I already added exception breakpoint. All the instance variables and the properties have the normal values. I can go back and forth between the main menu and the mapview without any problem if I don't add the annotations. In the mapview I have a small button which drops the annotations. The annotations dropped nice, but now if I pressed the back button the app crash! You can also see the following code http://mralek.se/post/9591337792/easy-custom-mkpinannotationview-with-pin-drop in order to see how annotations dropped – Anestis Tsoulfas Feb 19 '14 at 09:20
  • do you get the same error even after using the exception breakpoint? or does it highlight some other line in your code? – GoGreen Feb 19 '14 at 09:27
  • Yes the error is the same. If I don't add the annotations, the app works just fine! Back and forth the views, no memory problem, nothing!. When I add the annotations and I pressed the back button crashed! Please check also this example http://mralek.se/post/9591337792/easy-custom-mkpinannotationview-with-pin-drop because annotations drop with the same effect. – Anestis Tsoulfas Feb 19 '14 at 09:34
  • You mentioned that you _"have a small button which drops the annotations"_. Is that the same as `- (IBAction)backPressed:(id)sender`? – GoGreen Feb 19 '14 at 09:35
  • No, this is the back button. – Anestis Tsoulfas Feb 19 '14 at 09:36
  • ok. I think you are getting confused between the back button code and the other button code. what is the code you use for the other button? – GoGreen Feb 19 '14 at 09:38
  • check above (the reload button) – Anestis Tsoulfas Feb 19 '14 at 09:42
  • Why are you adding the annotations again in reload button? `[self.mapView addAnnotations:self.annotations];` – GoGreen Feb 19 '14 at 09:47
  • and also please avoid implementing the back button of your navigation bar. you can write the `same code` that you wrote in `backPressed:(id)sender` to the `viewDidDisappear` method instead. try doing that. – GoGreen Feb 19 '14 at 09:55
  • i delete and add again the annotations using the reload button, later in the development I will take this info from database, so may will be different.....Why viewDidDisappear didn't call when I pressed the back button!? – Anestis Tsoulfas Feb 19 '14 at 10:17
  • It must get called. are you adding the back button explicitly in your xib? if so, you need not do it that way as it is comes automatically with the navigation bar and remove any outlet connections that you have made to it. – GoGreen Feb 19 '14 at 10:29
  • I don't want the navigation bar :) That's why i have a custom button. Also I found somewhere that: Normally, if you use a navigation controller, and go back to a previous view with one of the pop methods, viewDidLoad does not get called again, because the view are not unloaded yet....I will try again :) – Anestis Tsoulfas Feb 19 '14 at 10:32
  • I also used the default navigation bar of the navigation controller. The same again! :( – Anestis Tsoulfas Feb 19 '14 at 10:46
  • What if you comment out the code `[self.mapView removeAnnotations:self.mapView.annotations]; [self.mapView removeOverlays:self.mapView.overlays];` in the backbutton pressed function. does that make any difference ? – GoGreen Feb 19 '14 at 11:06
  • I did it already! Same error! :(. If you want and you have time download this example from http://mralek.se/post/9591337792/easy-custom-mkpinannotationview-with-pin-drop and use a navigation control to see the results!... – Anestis Tsoulfas Feb 19 '14 at 11:45
  • I think the problem is in how you are pushing to the mapviewcontroller to the navigation stack, and how you remove it using the back button.can you share your code via git or somethin? – GoGreen Feb 19 '14 at 11:55
  • Ok, but then why I don't have any problem If I don't add the annotations? In the case everything is ok! – Anestis Tsoulfas Feb 19 '14 at 12:01
  • if you don't need a navigation bar and you are customizing the back button, then it's better to entirely drop the idea of using the `navigationController`. You can present and dismiss the `mapViewController` [modally](http://stackoverflow.com/questions/1529632/present-and-dismiss-modal-view-controller) instead. – GoGreen Feb 19 '14 at 12:01
  • regarding that, I cant say until i look into your code. – GoGreen Feb 19 '14 at 12:02
  • I will try first to use a SidePanel solution... I will let you know! Thank you :) – Anestis Tsoulfas Feb 19 '14 at 14:34
  • ok. good luck with that! :) – GoGreen Feb 20 '14 at 06:00
  • Finally I used a sideslide solution and everything is ok! :) – Anestis Tsoulfas Feb 20 '14 at 07:42

0 Answers0