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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:35+00:00 2026-05-25T20:37:35+00:00

I’m stuck in a weird problem. I am currently working on mapkit on iPhone.

  • 0

I’m stuck in a weird problem. I am currently working on mapkit on iPhone. I need to show two routes in my map, for which there is a source city and two different destination. For a route between two cities my code was fine. for that purpose in one place in my code i was doing like this….

- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSString *)endPoint options:(UICGDirectionsOptions *)options {
[googleMapsAPI stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, endPoint, [options JSONRepresentation]]];
}

In the above code stringByEvaluatingJavaScriptFromString was passing javascript to my delegate method due to which route was drawn.
Now, i have to draw two different routes, for that purpose i have changed above code like this..

- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSMutableArray *)endPoints options:(UICGDirectionsOptions *)options {
    for (int idx = 0; idx < [endPoints count];idx ++) 
    {
        NSString* msg = [NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, [endPoints objectAtIndex:idx], [options JSONRepresentation]];
        mstr = [msg retain];
        if (idx == 0)
        {
            [googleMapsAPI stringByEvaluatingJavaScriptFromString:msg];
        }
        else {
            [NSThread detachNewThreadSelector:@selector(loadroute:) toTarget:self withObject:mstr];
        }
    }
}

i have the following to create and implement NSThread.

-(void)loadroute :(NSString *)message
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    [self performSelectorOnMainThread:@selector(loadComplete:) withObject:message waitUntilDone:YES];
    [pool release];

}

-(void)loadComplete:(NSString *)message
{
    [googleMapsAPI stringByEvaluatingJavaScriptFromString:message];
}

here, i have created another thread due to which i would be able to pass strings to stringByEvaluatingJavaScriptFromString separately.
But only the last string is passed to the delegate method.What i’m missing? please help me out. i’m stuck in this weird problem since last week. Any help would be appreciated. Thnx 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-25T20:37:35+00:00Added an answer on May 25, 2026 at 8:37 pm

    As suggested by Ali u can go wid..performSelector:withObject:afterDelay:it will give u desired result..
    u can write ur code like..

     - (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSMutableArray *)endPoints options:(UICGDirectionsOptions *)options {
                for (int idx = 0; idx < [endPoints count];idx ++) 
                {
        NSString* msg = [NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, [endPoints objectAtIndex:idx], [options JSONRepresentation]];
                mstr = [msg retain];
    
                 [self performSelector:@selector(loadComplete:) withObject:nil afterDelay:0.5];
                }
            }
    
    -(void)loadComplete:(NSString *)message
     {
            [googleMapsAPI stringByEvaluatingJavaScriptFromString:message];
     }
    

    Hope this will help u out.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I used javascript for loading a picture on my website depending on which small
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm parsing an XML file, the creators of it stuck in a bunch social

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.