美文网首页
JavaScriptCore框架 _JSValue(1)

JavaScriptCore框架 _JSValue(1)

作者: by小杰 | 来源:发表于2016-09-29 17:33 被阅读12次
//导入头文件
#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);

相关文章

网友评论

      本文标题:JavaScriptCore框架 _JSValue(1)

      本文链接:https://www.haomeiwen.com/subject/stqlyttx.html