Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:22:13+00:00 2026-05-31T00:22:13+00:00

In my viewcontroller I use Maps and I load a list of pins. When

  • 0

In my viewcontroller I use Maps and I load a list of pins.
When I move the map or zoom in or out it, my app crashes and displays this error:

[GMMGeoTileImageData isEqualToString:]: unrecognized selector sent to instance 0x862d3b0

This is my code of the view controller:

    - (void)viewDidLoad
    {

        statoAnn = [[NSMutableString alloc] initWithFormat:@"false"];

        //bottone annulla per tornare indietro
        UIBarButtonItem *annullaButton = [[[UIBarButtonItem alloc] initWithTitle:@"Annulla" style:UIBarButtonItemStylePlain target:self action:@selector(backView)] autorelease];
        self.navigationItem.leftBarButtonItem = annullaButton;


        //inizializzo la mappa
        mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 416)];
        mapView.delegate = self;
        mapView.mapType = MKMapTypeStandard;
        [self.view addSubview:mapView];

        [self setGmaps:arrData];

        [super viewDidLoad];
    }


/** inizializzo l'annotation del poi mappa **/
- (void) setGmaps:(NSMutableArray*)inputData { 

    // setto la lat e lng 
    CLLocationDegrees latitude;
    CLLocationDegrees longitude;
    CLLocationCoordinate2D poiLocation;
    arrAnn = [[NSMutableArray alloc] init];

    for(int i=0; i<[inputData count]; i++) {

        //ricavo la lat e lng del pin
        latitude  = [[[inputData objectAtIndex:i] objectForKey:@"latitude"]  doubleValue];
        longitude = [[[inputData objectAtIndex:i] objectForKey:@"longitude"] doubleValue];

        // setto la location del poi
        poiLocation.latitude = latitude;
        poiLocation.longitude = longitude;
        //[[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] autorelease];

        //setto il pin
        Annotation *ann = [[Annotation alloc] initWithCoordinate:poiLocation];
        ann.title = [[inputData objectAtIndex:i] objectForKey:@"label"];
        [arrAnn addObject:ann];
        [ann release]; 

    }


    if (nil != self.arrAnn) {

        [self.mapView addAnnotations:arrAnn];
        //self.ann = nil;
        self.arrAnn = nil;
    }

}

/** setto il pin nella mappa ***/
- (void)setCurrentLocation:(CLLocation *)location {

    MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};

    region.center = location.coordinate;

    region.span.longitudeDelta = 0.1f;
    region.span.latitudeDelta  = 0.1f;

    [self.mapView setRegion:region animated:YES];
    [self.mapView regionThatFits:region];
}


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

    MKPinAnnotationView *view = nil; // return nil for the current user location

        view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];

        if (nil == view) {
            view = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"identifier"] autorelease];
            view.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        }

        [view setPinColor:MKPinAnnotationColorPurple];
        [view setCanShowCallout:YES];
        [view setAnimatesDrop:YES];

    if (![statoAnn isEqualToString:@"true"]) {
        CLLocation *location = [[CLLocation alloc] initWithLatitude:annotation.coordinate.latitude
                                                          longitude:annotation.coordinate.longitude];
        [self setCurrentLocation:location];
        statoAnn = [NSMutableString stringWithFormat:@"true"];
    } 


    return view;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:22:14+00:00Added an answer on May 31, 2026 at 12:22 am

    In viewForAnnotation, this line:

    statoAnn = [NSMutableString stringWithFormat:@"true"];
    

    sets statoAnn to an autoreleased string.

    When the method exits, release is called on statoAnn and it no longer owns the memory it was pointing to. When the method is called again when you zoom or move the map, the memory that statoAnn was pointing to is now used by something else (GMMGeoTileImageData in this case). That object is not an NSString and doesn’t have an isEqualToString: method and you get the error you are seeing.

    To fix this, set statoAnn so the value is retained like you are doing in viewDidLoad. For example, you could change it to:

    statoAnn = [[NSMutableString alloc] initWithFormat:@"true"];
    

    You could also declare statoAnn as a property (@property (nonatomic, copy) NSString *statoAnn) and just set it using self.statoAnn = @"true";. The property setter will do the retaining for you.

    However, you don’t need to use a string to hold a “true” and “false” value. It’s much easier and efficient to use a plain BOOL and you won’t have to worry about retain/release since it’s a primitive type and not an object.

    The other thing is that viewForAnnotation is not the right place to be setting the map view’s region in the first place. You can do that in viewDidLoad after the annotations are added.

    Another thing: At the top of viewForAnnotation, you have the comment “return nil for the current user location” but that code doesn’t do that. It just initializes the view to nil. To actually do what the comment says, you need this:

    MKPinAnnotationView *view = nil; 
    
    // return nil for the current user location...
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    

    Finally, if the dequeueReusableAnnotationViewWithIdentifier does return a view (if view != nil), you need to set view.annotation to the current annotation since the re-used view may have been for a different annotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use this line of code in the viewDidLoad of the app's main
I'm wondering what happens when I use a MKReverseGeocoderDelegate in my ViewController, but the
How to use AppDelegate in other ViewController and What is the use of using
I use the following code to add cocos2d scene to a viewcontroller - (void)viewDidLoad
My project using ARC, so I can't use retain nor release, in ViewController A,
I need to use uimenucontroller in my app, where i want copy/paste/etc options, when
i'm developing an app for iphone, and i use [self presentModalViewController:aViewControllerInitializateBefore animated:YES]; Can you
I use a .xib to layout my viewController and have 10 IBOutlet objects that
Actually, i have some values calculated in my viewController.m of my project.And i use
From my viewcontroller view I am loading a xib file. I want this view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.