JavaScriptCore框架 _JSValue(1)

2016-09-29  本文已影响12人  by小杰
//导入头文件
#import <JSPatchPlatform/JSPatch.h>

#pragma mark ------ 1.JSValue 声明代理及属性 -------
! 代理一定要继承与 JSExport
@protocol ViewControllerDelegate <JSExport>
@property (nonatomic, strong) NSString *name;
@end
#pragma mark ------ 2.JSValue  遵循代理 -------
@interface ViewController ()<ViewControllerDelegate>

@end```

pragma mark ------ 3.JSValue 、添加setter和getter方法 ------

@synthesize name;


pragma mark ------ 4. JSValue (改变属性的值)-------

JSContext *context = [[JSContext alloc] init];
self.name = @"大白好";

context[@"s"] = self;

[context evaluateScript:@"s.name = '真帅'"];

NSLog(@"%@", self.name);
上一篇 下一篇

猜你喜欢

热点阅读