Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem in passing multiple strings to stringByEvaluatingJavaScriptFromString
    primarykey
    data
    text
    <p>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….</p> <pre><code>- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSString *)endPoint options:(UICGDirectionsOptions *)options { [googleMapsAPI stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, endPoint, [options JSONRepresentation]]]; } </code></pre> <p>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..</p> <pre><code>- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSMutableArray *)endPoints options:(UICGDirectionsOptions *)options { for (int idx = 0; idx &lt; [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]; } } } </code></pre> <p>i have the following to create and implement NSThread.</p> <pre><code>-(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]; } </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload