How to pass a ObjectiveC string Variable to a javascript function? I have just started with javascript.. so plz 4give my ignorance...
Asked
Active
Viewed 5,532 times
3
-
Some more information would be useful. Maybe a code snippet? – Aatch Sep 04 '10 at 12:04
-
Suppose the JS function is myFunc(var arg1) I Have NSString * str = some value. Now, [webView stringByEvaluatingJavaScriptFromString:.......] Here how to pass the str as a argument to the Js function myFunc() – djk Sep 04 '10 at 12:32
2 Answers
12
NSString * param = @"foo";
NSString * jsCallBack = [NSString stringWithFormat:@"myFunc('%@')",param];
[webView stringByEvaluatingJavaScriptFromString:jsCallBack];

Aaron Saunders
- 33,180
- 5
- 60
- 80
-
1
-
1Is there any alternate way. I am trying to pass my complete web-service response so it is crashing. – Warrior Aug 24 '15 at 20:00