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

this method [bridge setWebViewDelegate:(id)webViewDelegate] will cause circular reference #276

Open
GarenChen opened this issue Mar 27, 2017 · 3 comments

Comments

@GarenChen
Copy link

it seams that this method :
[bridge setWebViewDelegate:(id)webViewDelegate] will cause circular reference in swift 3.0 project 。I pass a self(UIViewController) to this method, finally this controller didn't call "deinit" when I popViewController

@szcsab
Copy link

szcsab commented Apr 4, 2017

Same here with ObjC

@GarenChen
Copy link
Author

In the WebViewJavascriptBridge source code ,it make the webViewDelegate as strong referance :
__strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate;

Thus we must cut off the reference cycle manually:

//set up the delegate
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.bridge.setWebViewDelegate(self)
}

//set the delegate nil
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.bridge.setWebViewDelegate(nil)
}

@Young-Li-wxx
Copy link

@GarenChen it not work

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

3 participants