I have a simple javascript function that takes two variables. I need to pass two variables that I already have in an Objective-C (iOS) application for this javascript function. My line of code to run javascript:
[webView stringByEvaluatingJavaScriptFromString:@"onScan()"];
The javascript function simply applies two variables to the HTML form and submits it. Of course, I get undefined in my form since there are no variables. 8-) I could not find a lot of documentation about this, but maybe I was looking for the wrong place?
FWIW, my Objective-C variables are strings. My javascript onscan(a,b)
function onscan(a,b)
UPDATE:
I managed to get this working by putting single quotes around each of the variables passed to the javascript function. Updated code:
[webView stringByEvaluatingJavaScriptFromString:@"onScan('%@','%@')",a,b];
source share