Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYBJsObjCModel对象会泄露 #2

Open
AgoniNemo opened this issue Jul 12, 2017 · 0 comments
Open

HYBJsObjCModel对象会泄露 #2

AgoniNemo opened this issue Jul 12, 2017 · 0 comments

Comments

@AgoniNemo
Copy link

AgoniNemo commented Jul 12, 2017

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对象会泄露

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant