Skip to content

HYBJsObjCModel对象会泄露 #2

Description

@AgoniNemo
self.jsContext = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
// 通过模型调用方法,这种方式更好些。
HYBJsObjCModel *model = [[HYBJsObjCModel alloc] init];
self.jsContext[@"OCModel"] = model;
model.jsContext = self.jsContext;
model.webView = self.webView;
self.jsContext.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) {
context.exception = exceptionValue;
NSLog(@"异常信息:%@", exceptionValue);
};

当我把以上代码放到[self.view addSubview:self.webView];之后
在JavaScriptObjectiveCDelegate添加方法
-(NSString *)getToken;

在HYBJsObjCModel里添加方法

-(NSString *)getToken{
return @"HYBJsObjCModel的token";
}

在test.html里添加方法

<script>
var string = OCModel.getToken();
alert(string);
</script>

会造成HYBJsObjCModel对象会泄露

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions