-
Re: how to pass large data to UIWebView javascript from Objective-C
eskimo Nov 25, 2016 12:22 AM (in response to JIAT)First up, if you’re using UIWebView you should consider making the switch to WKWebView; it’s the future of web views on our platforms.
Second, define “large” in this context? Hundreds of KiB? MiB? Tens of MiB?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: how to pass large data to UIWebView javascript from Objective-C
JIAT Nov 25, 2016 9:25 AM (in response to eskimo)Thanks for your information.
The size of html content that needs to be passed from obj-c to js is around 40KB.
-
Re: how to pass large data to UIWebView javascript from Objective-C
eskimo Nov 25, 2016 1:43 PM (in response to JIAT)Oh wow, much smaller than I expected. At that size I’d just wrap the HTML in a JavaScript string and pass that in to the web view via
-stringByEvaluatingJavaScriptFromString:
.Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: how to pass large data to UIWebView javascript from Objective-C
JIAT Nov 28, 2016 9:41 PM (in response to eskimo)Thank you.
Could you please give me a sample on how to wrap the HTML in a JavaScript string?
-
Re: how to pass large data to UIWebView javascript from Objective-C
JIAT Nov 28, 2016 11:13 PM (in response to eskimo)I've tried in the following way to send NSString variable conte to pass to the javascript function otverse(t)
Length of conte : 4223
in objective-c
NSString *fun = [NSString stringWithFormat:@"otverse(['%@'])",conte];
[self.webView stringByEvaluatingJavaScriptFromString:fun];
in javascript from html file
function otverse(t)
{
alert("Result from obj-c " + t);
}
But the function otverse is not called.
-
Re: how to pass large data to UIWebView javascript from Objective-C
JIAT Nov 28, 2016 11:18 PM (in response to eskimo)Further if i call the javascript function otverse with small string, it is invoked.
Could you help me to pass string of length more than 1000 to javascript from obj-c.
Thanks in advance.
-
-
-