码迷,mamicode.com
首页 > 编程语言 > 详细

利用JavaScriptCore实现以下简单的功能(平方和)

时间:2015-07-16 11:06:07      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

 1 #import "RootViewController.h"
 2 #import <JavaScriptCore/JavaScriptCore.h>
 3 
 4 @interface RootViewController ()<UIWebViewDelegate>
 5 @end
 6 
 7 @implementation RootViewController
 8 
 9 - (void)viewDidLoad {
10     [super viewDidLoad];
11     
12     JSContext *context = [[JSContext alloc] init];
13     [context evaluateScript:@"var square = function(x){return x*x;}"];
14     JSValue *squareFunction = context[@"square"];
15     JSValue *nineSquared = [squareFunction callWithArguments:@[@9]];
16     NSLog(@"9^2:%@",nineSquared);
17     
18 }
19 
20 @end

 

利用JavaScriptCore实现以下简单的功能(平方和)

标签:

原文地址:http://www.cnblogs.com/lantu1989/p/4650349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!