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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:49:34+00:00 2026-06-02T06:49:34+00:00

I am trying draw route between two location.For that i have two instance of

  • 0

I am trying draw route between two location.For that i have two instance of CLLocation startPoin,endPoind. I want to convert this two location two corresponding Location Address.After that i want to fetch all route points from Google map webservice. So did the following code.

- (void)viewDidLoad{
    [super viewDidLoad];
    locations =[[NSMutableArray alloc]initWithCapacity:2];//For location Name 
    [self.mapView_MP setMapType:MKMapTypeStandard];
    [self.mapView_MP setZoomEnabled:YES];
    [self.mapView_MP setScrollEnabled:YES];
    [self update:startPoint];  //MKReverseGeocoder start point  
    [self update:endPoint];    //MKReverseGeocoder end point

    [self updateRoute];

}

- (void)update:(CLLocation*)loc{
    MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:loc.coordinate];


    geoCoder.delegate = self;
    [geoCoder start];

}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{

    NSMutableDictionary *cplace=[[NSMutableDictionary alloc]initWithDictionary:[placemark addressDictionary]];

   // NSLog(@"The geocoder has returned: %@", [cplace objectForKey:@"FormattedAddressLines"] );
   // NSLog(@"The geocoder has returned: %@", [cplace objectForKey:@"Street"] );
    [locations addObject:[cplace objectForKey:@"SubAdministrativeArea"]];
     NSLog(@"The geocoder has returned: %@", locations );
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
    NSLog(@"reverseGeocoder:%@ didFailWithError:%@", geocoder, error);
}

- (void)updateRoute {

    self.responseData=[NSMutableData data];  
    NSLog(@" string Formate.................................===%@",locations);   

    NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&mode=driving&sensor=false", [locations objectAtIndex:0],[locations objectAtIndex:1]]]];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];    
}

In viewDidLoad i am calling the methods in the order

[self update:startPoint];      //MKReverseGeocoder start point  
    [self update:endPoint];    //MKReverseGeocoder end point           
    [self updateRoute];

but unfortunately [self updateRoute]; is executing first compare to MKReverseGeocoder delegate method. there for the location array is null in side this method. Getting EXEBADACCESS. how can i over come this value.
Inside MKReverseGeocoder delegate method i got location name. the Delegate methods is executing any other thread.

  • 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-06-02T06:49:50+00:00Added an answer on June 2, 2026 at 6:49 am

    MKReverseGeocoder is deprecated in iOS 5, so you should probably use CLGeocoder instead.

    That aside, yes, the start method is asynchronous, as indicated in the documentation. That doesn’t necessarily mean that you’ll get the results on a different thread, but it means that the method will usually return before results are available.

    You need to keep track of your geocoders to call your updateRoute method when both have finished.

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

Sidebar

Related Questions

I am trying to draw route between two location. For that i have Two
I am trying two draw route between two location,For that I Fetch all the
I'm trying to draw a route in a mapView from the current location (got
I used this function to draw a path between two points. I get the
I'm trying to draw a route onto my MapView. I've extended Overlay and implemented
basically i am trying to draw the path i.e road path. for that i
I'm trying to draw items that end of them is an * character in
I'm trying to plot lines between two or more addresses in Google Maps. The
I am trying to draw a bus route as a simple sequence of lines.
I am trying to calculate the distance between two map point using Google Map

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.