用
self.context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
取得 JSContext 的方法会不会审核被拒?
查了下拒不拒都有例子。。不敢用了都
1
jhdxr 2015-09-07 11:29:16 +08:00 1
没因为这个悲剧过
|
2
lynulzy 2015-09-07 13:09:00 +08:00 1
为什么会悲剧
|
3
siroccoicode 2015-09-07 13:55:20 +08:00
不会,从 iOS8.2 开始允许使用 JavascriptCore 来动态执行代码。
|
5
xi_lin OP @lynulzy 因为 documentView.webView.mainFrame.javaScriptContext 不在官方文档里
|
6
xi_lin OP @siroccoicode 在 iOS7 上用呢?
|
7
DingSoung 2015-09-07 14:47:52 +08:00 1
不会,用过。
|
8
lynulzy 2015-09-07 15:06:37 +08:00
和这个方法的效果一样吧?
- stringByEvaluatingJavaScriptFromString: |
9
siroccoicode 2015-09-07 20:45:07 +08:00
@xi_lin 准确说是从 iOS7 开始公开了 JSC 的接口,发布 iOS8.2 的时候修改了开发者协议,内容如下
> 3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework, provided that such scripts and code do not change the primary purpose of the Application by providing features or functionality that are inconsistent with the intended and advertised purpose of the Application as submitted to the App Store. 实际上就意味着允许开发者直接使用 JavascriptCore 接口来进行一些更加``奇妙``的操作 |
11
xi_lin OP @lynulzy 主要是想简化 js -> native 这一步,有了 JSContext 就可以直接 JSExport 直接调用方法了
|
12
xi_lin OP @siroccoicode 原来如此,谢谢!
|