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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:55:33+00:00 2026-05-25T18:55:33+00:00

I have the following Objective-C code: NSString *urlStr=[[NSString alloc] initWithFormat:@http://www.prestocab.com/driver/ajax/getFriendsOnMap.php]; NSURL *url=[NSURL URLWithString:urlStr]; __block

  • 0

I have the following Objective-C code:

NSString *urlStr=[[NSString alloc] initWithFormat:@"http://www.prestocab.com/driver/ajax/getFriendsOnMap.php"];
    NSURL *url=[NSURL URLWithString:urlStr];

    __block ASIFormDataRequest *request=[[ASIFormDataRequest alloc ]initWithURL:url];

    [request setDelegate:self];
    [request setPostValue:[NSString stringWithFormat:@"%f",swCoord.latitude ] forKey:@"sw_lat"];
    [request setPostValue:[NSString stringWithFormat:@"%f",swCoord.longitude ] forKey:@"sw_lng"];
    [request setPostValue:[NSString stringWithFormat:@"%f",neCoord.latitude ] forKey:@"ne_lat"];
    [request setPostValue:[NSString stringWithFormat:@"%f",neCoord.longitude ] forKey:@"ne_lng"];

    [request setCompletionBlock:^{
        NSLog(@"%@",[request responseString]);
        SBJsonParser *parser=[[SBJsonParser alloc]init];
        //NSDictionary *obj=[parser objectWithString:[request responseString] error:nil];
        NSDictionary *arr=[parser objectWithString:[request responseString] error:nil];

        MapViewAnnotation *annotation=[[MapViewAnnotation alloc]init];
        for(int i=0;i<arr.count;i++){
            NSDictionary *obj=[arr objectForKey:[NSString stringWithFormat:@"%d",i]];
            CLLocationCoordinate2D coord;
            coord.latitude=[[obj objectForKey:@"lat"] doubleValue];
            coord.longitude=[[obj objectForKey:@"lng"] doubleValue];
            [annotation initWithTitle:[obj objectForKey:@"uname"] andCoordinate:coord];

            //[self.mapView performSelectorOnMainThread:@selector(addAnnotation) withObject:annotation waitUntilDone:YES];
            [self.mapView addAnnotation:annotation];

        }
        [annotation release];
        //[self.mapView addAnnotations:annotations];
        //[annotations release];
    }];
    [request setFailedBlock:^{

    }];
    [request startAsynchronous];

As you can see, I’m getting some data from my website using ASIHttpRequest, parsing the result and hoping to put annotations on the MKMapView.

Trouble is, when I call [self.mapView addAnnotation:…] I keep getting one of these EXC_BAD_ACCESS errors that I simply cannot get to the bottom of.

Anyone have any suggestions?

Many thanks in advance,

  • 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-25T18:55:33+00:00Added an answer on May 25, 2026 at 6:55 pm

    you get BAD_ACCESS because either the mapView or the annotation is already destroyed but you have a pointer to that instances. I guess that you dont retain the mapView. You can check these kind of errors by turning on the NSZombies and by enabling stop on exception.

    Or put this code before the line of code where the error happens:

    NSLog(@"mapView-desc: %@",[self.mapView description]);
    NSLog(@"annotation-desc: %@",[annotation description]);
    

    The BAD_ACCESS should now happen in one of these two lines and then you know on which obejct you have forgotten to retain 😉 If there is all fine then the problem is inside mapView or the data in your annotations. The easiest way is to enable NSZombies and wait for messages in your console.

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

Sidebar

Related Questions

I have a piece of Objective-C code that looks like the following: - (NSString
Say I have the following Objective-C class: @interface Foo { int someNumber; NSString *someString;
I have the following Objective C test code in a SenTestCase class. I get
I have the following code in Objective-C for the iPhone, using NSDateFormatter: NSDate *today
I have Objective C code creating an NSUrlConnection as follows: //prepar request NSString *urlString
Basically, I have the following code (explained here: Objective-C Constants in Protocol ) //
I have created the following POST method via objective-C -(IBAction) postLocation: (id) sender{ NSString
I would like to define the following function in Objective-C. I have provided pseudo-code
I have been following this useful-looking article http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/ . Unfortunately he doesn't hint at
I have a question about the objective-C. I use the following code to add

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.