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 947195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:02:47+00:00 2026-05-15T23:02:47+00:00

I am writing an iPhone app where the user is supposed to be able

  • 0

I am writing an iPhone app where the user is supposed to be able to turn on and turn off all the pins on the map. To put all the pins on the map I use:

-(void) putAllPins {
    for (id key in myDictionary) { //A NSDictionary
        NSArray *data = [myDictionary objectForKey:key];
        [self putPin: data];
    }
    isShowingAllPins = TRUE;
}

-(CLLocationCoordinate2D) putPin:(NSArray *) data {
    NSNumber *lat = [data objectAtIndex:0];
    NSNumber *lon = [data objectAtIndex:1];
    NSString *name = [data objectAtIndex:2];
    NSString *info = [data objectAtIndex:3];

    CLLocationCoordinate2D coords = {[lat doubleValue], [lon doubleValue]};
    MyMapAnnotation *annotation = [[MyMapAnnotation alloc] initWithCoordinate:coords andName:name andInformation:info];
    [_mapView addAnnotation:annotation];
    [annotation release];
    return coords;
}

To remove them I use:

-(void) removeAllPins {
    NSMutableArray *toRemove = [NSMutableArray  arrayWithCapacity:([_mapView.annotations count] - 1)];
    for (id annotation in _mapView.annotations) {
        if (annotation != _mapView.userLocation) {
            [toRemove addObject:annotation];
        }
    }

    [_mapView removeAnnotations:toRemove];
}

It works fine to remove all the pins once and add them again. But as soon as I remove them a second time I get an EXC_BAD_ACCESS error. I have traced the problem to the dealloc method in my annotation class, but still don’t know what to do. Any help is appreciated!

MyAnnotation.m:

@implementation MyAnnotation

@synthesize coordinate = _coordinate;

-(id) initWithCoordinate:(CLLocationCoordinate2D)coordinate andName:(NSString *)name andInformation:(NSString *)info {
    self = [super init];
    _coordinate = coordinate;
    _name = name;
    _info = info;

    return self;
}

-(NSString *)title {
    return [NSString stringWithFormat:@"PREFIX %@", _name];
}

-(NSString *)subtitle {
    return _info;
}

- (void)dealloc {
    [_name release];
    [_info release];
    [super dealloc];
}

@end
  • 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-15T23:02:48+00:00Added an answer on May 15, 2026 at 11:02 pm

    Try tip #1 here

    http://loufranco.com/blog/files/debugging-memory-iphone.html

    You set Xcode so that objects aren’t really released, and they complain if you release deallocated objects or in some other way send them a message.

    Update: _name is never retained — and then you release it. Same with _info. If they are retained properties, you need to use self._name to use the generated set message (that retains)

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

Sidebar

Related Questions

I am writing an iPhone app that needs to be able to upload photos
I'm writing a simple iPhone app which lets a user access a series of
I am currently writing a multi-user social iPhone app which interfaces with a server.
I'm writing my first iPhone app, so I haven't gotten around to figuring out
I'm writing server-side programs in PHP for an iPhone app. And I have no
So I'm looking at writing an iPhone application that shows things on a map.
Writing an iPhone app in Objective-C, I have a date in string form (in
Im writing an iPhone app which retrieves data from a web service as XML.
I'm writing an iPhone app. I want a UIImagePicker control to come up when
I'm writing an iPhone app for a client, and they have requested a feature

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.