Note that there are some explanatory texts on larger screens.

plurals
  1. POaddAnnotations issue (memory management maybe?)
    text
    copied!<p>I'm having some problem with MKMapView / annotations / UINavigationController. Basically, i manage my views using a UINavigationController; one of my view contains an MKMapView and i add annotations on it (10 to 200) using the addAnnotations method.</p> <p>Everything is working fine except for one thing : if i navigate "too fast" on my UINavigationController, the iphone simulator crashes, receiving an "EXC BAD ACCESS" signal. For example, if i load my view containing the MKMapView and immediatly press the "Back" button from the UINavigationController navigation bar, i get the signal. I figured that the problem was with the addAnnotations method : when my MKMapView is loaded, i add annotations to it but it looks like everything is done asynchronously. If i wait like a second before pushing the "Back" button, i get no error but if i'm too fast, it crashes. I get no error at all if i remove the addAnnotations line. I guess it's because my view is released by the UINavigationController BEFORE the addAnnotations method got the job done.</p> <p>Any good solution to this? I don't want the user to wait (displaying a loading view for example); i guess the solution might be a better memory management but i don't see how i could do this.</p> <pre><code> if(DEBUG_MODE) { NSLog(@"Creating array of placemarks : begin"); } self.placemarkCache = [[NSMutableArray alloc] init]; // Loading placemarks for a placemark dictionary NSArray *sortedKeys = [[self.placemarkDictionary allKeys] sortedArrayUsingSelector:@selector(compare:)]; for (id key in sortedKeys) { MyPlacemark *currentPlacemark = [self.placemarkDictionary objectForKey:key]; [self.placemarkCache addObject:currentPlacemark]; [currentPlacemark release]; } if(DEBUG_MODE) { NSLog(@"Creating array of placemarks : done"); } if(DEBUG_MODE) { NSLog(@"Adding placemarks : begin"); } [self.mapView addAnnotations:self.placemarkCache]; if(DEBUG_MODE) { NSLog(@"Adding placemarks : done"); } </code></pre> <p>On this example, i get the "Adding placemarks : done" message before anything get displayed on the map.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload