I\'ve a great problem. I must pass a variable of a javascript function into an objective-C variable. These are my code\'s parts:
Javascript:
functi
You wan to call the function, not just refer to it:
myLabel.text = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent()"];
the key bit is at the end:
...documentElement.textContent()"];
// ^^
Since JavaScript functions are first-class objects, when you do:
x = functionName;
...x receives a reference to the function. In your case, since the UIWebView then coerces it to a string, you end up calling toString on the function, which on most JavaScript implementations gives you the code of the function (although this is not specified by any standard).
To actually call a function, you put parentheses after it (with nothing in them, if there are no arguments you need to pass; or with arguments in them if you do), e.g.:
x = functionName();
Disclosure: I know nothing about iOS development, Objective-C, or UIWebView, but I was able to quickly find the stringByEvaluatingJavaScriptFromString function you were using, and then confirmed via this page that the string after the @ needs to be valid JavaScript code.