JavaScriptCore is an important component of webkit, mainly for parsing JS and providing the execution environment. The following article describes how to use JavaScriptCore to implement interaction between OC and JS. This article is very detailed. For more information, see. # Wiki/48.html "target =" _ blank "> JavaScriptCore is an important component of webkit. It mainly parses JS and provides an execution environment. The following article describes how to use JavaScriptCore to implement interaction between OC and JS. This article is very detailed. For more information, see.
JavascriptCore
JavascriptCore is an important component of webkit, mainly for parsing JS and providing the execution environment. After iOS 7, Apple launched it on the iPhone platform, greatly facilitating js operations.
First, create a webView to read the local html file.
NSURL* htmlURL = [[NSBundle mainBundle] URLForResource: @"demo" withExtension: @"html"];[_webView loadRequest: [NSURLRequest requestWithURL: htmlURL]];
In the demo, we need to implement four situations
JS calls OC
JS calls OC and passes Parameters
OC calls JS
OC calls JS and passes Parameters
The code in the html file is as follows: