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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:32:32+00:00 2026-05-25T22:32:32+00:00

I wanna to know abt stringByEvaluatingJavaScriptFromString . According to the apple doc. The result

  • 0

I wanna to know abt "stringByEvaluatingJavaScriptFromString".

According to the apple doc.
"The result of running script or nil if it fails."

I have a method in which inside a for loop i’m passing a string value to stringByEvaluatingJavaScriptFromString. what will it do ?? will this get response for every string or something else will happen??
I was doing 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]];
        [googleMapsAPI stringByEvaluatingJavaScriptFromString:msg];
    }
}

Inorder to get response to every string what should I do? I think that it should get response to every string that i’m passing here. Please tell me what m doing wrong and how would i manipulate my code to get response to all strings that m passing.
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-25T22:32:33+00:00Added an answer on May 25, 2026 at 10:32 pm

    You should make your javascript method to return a default string or something if even an error occurs in the script.

    function loadDirections()
    {
    
    try
      {
      //Your code goes here which returns some result
      }
    catch(err)
      {
      var errorFlag = "ERROR";
    return errorFlag;
      }
    }
    

    and then you should alter your Objective C code like below

    NSString *msg = [NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, [endPoints objectAtIndex:idx], [options JSONRepresentation]];
    
    if([msg isEqualToString:@"ERROR")
    {
    
    //Do some error handling
    
    }
    else
    {
    
    //Your actual code goes here
    
    }
    

    Update for the comment:

    To solve your javascript asynchronous problem either (1) you can change your design and call the javascript method only after getting response from the first call (2) or else you can use NSTimer which will will give a little time for the execution. In my opinion changing your design as per the first option would be perfect.

    Have a look at these questions
    stringByEvaluatingJavaScriptFromString doesn't always seem to work
    return value javascript UIWebView

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

Sidebar

Related Questions

I wanna know study what to get which certificate in Java .. I need
I have a list of email ids. some bounce. i wanna know how i
I wanna know a corresponding method in Android/Java that is like the GetTickCount method
I wanna know is it possible to make an operating like windows-xp which is
jQuery - ajax success parameter i wanna know how to give a object method
I Have a data template that i use in items control, i wanna know
I have created a web site, and i'll publish it... I wanna know if
I wanna know for each home screen folder(created by the user), which apps are
I wanna know if this is possible. I have an external .css file in
I have the following file: Song - Arist.mp3 i wanna know how to change

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.