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

IQKeyboardReturnKeyHandler retain cycle #1228

Closed
godexsoft opened this issue Jan 18, 2018 · 7 comments
Closed

IQKeyboardReturnKeyHandler retain cycle #1228

godexsoft opened this issue Jan 18, 2018 · 7 comments
Milestone

Comments

@godexsoft
Copy link

In swift code i have IQKeyboardReturnKeyHandler as per documentation. Just adding the field and creating an instance from (controller: self) makes a retain cycle somehow. Easiest way to check is to add deinit method with a log line. Without IQKeyboardReturnKeyHandler the log line appears, with IQKeyboardReturnKeyHandler it does not - the controller stays in memory.

@hackiftekhar
Copy link
Owner

I'll check the memory and retain cycle issues. Thanks for letting me know about this.

@hackiftekhar
Copy link
Owner

I tried to fix memory issues with v5.0.8, let's see if that works for you.

@godexsoft
Copy link
Author

unfortunately it's still with the same result. deinit is not executed when creating instance from (controller: self).

@hackiftekhar
Copy link
Owner

You should release the IQReturnKeyHandler object wirh deinit of your ViewController. if it doesn't work then I'll try to take a look again.

@godexsoft
Copy link
Author

godexsoft commented Mar 14, 2018

But how can you release it in the deinit if deinit is never executed due to retain cycle? That's exactly the problem :)

What did work tho is this:

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)        
    returnKeyHandler = nil
 }

deinit {
    log.debug("now called")
}

@hackiftekhar
Copy link
Owner

okay, let me see then.

@hackiftekhar
Copy link
Owner

I got the point, it's because the IQKeyboardReturnKeyHandler is keeping reference of textField delegate and most of the time it's the ViewController who owns it. A fix is on the way.

@hackiftekhar hackiftekhar added this to the v6.0.0 milestone Mar 15, 2018
@hackiftekhar hackiftekhar reopened this Mar 15, 2018
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

2 participants