I am trying to send an array to a javascript function through a C object.
I call javascript function from my code with
stringByEvaluatingJavaScriptFromString
Now I am trying to pass an array of values ββto a javascript function.
This is what I tried -
- (void) webViewDidFinishLoad:(UIWebView *)webView { NSArray *array = [NSArray arrayWithObjects:@"10",@"9",@"8", nil]; string = [[array valueForKey:@"description"] componentsJoinedByString:@","]; [graphView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"methodName2(%@)", string]]; }
In my Javascript -
<script> function methodName(val) { alert(val); } </script>
However, in my warning message on the webview, only number 10 is displayed. Therefore, I feel like I am doing something wrong. Can someone tell me what I am doing wrong? Also, I will need to convert this string back to an array in javascript.
It would be great if someone helped me with this.
source share