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

Terminating app due to uncaught exception 'NSInternalInconsistencyException' #9

Closed
ghost opened this issue Apr 2, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Apr 2, 2017

I am getting this error, after I hit Back in the navigation controller. My ChatViewController (which uses ReverseExtension) is succesfully deiniting as you can see from the logs below, also another observer that I use (ContextWatcher) is deiniting as well.

I put a break point in deinit and the below error occures before the break point. Any ideas?

[00070]:ChatViewController.swift :deinit........................ :10:26:52 -------------------------
[00071]:ChatViewController.swift :deinit........................ :10:26:52 | ViewController deinit |
[00072]:ChatViewController.swift :deinit........................ :10:26:52 -------------------------
[00075]:CDContextWatcher.swift :deinit........................ :10:26:52 DEINIT ContextWatcher
2017-04-02 10:26:52.602283 LetsGoApp[401:153893] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x1031e0a00 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x1708390e0> (
<NSKeyValueObservance 0x170a5b780: Observer: 0x1701cb8b0, Key path: contentInset, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x17084d200>
)'

@marty-suzuki
Copy link
Owner

removeObserver is called this line.
But tableView might sometimes already be released because it is weak reference.
Please call tableView.removeObserver(self, forKeyPath: #keyPath(UITableView.contentInset)) in your ViewController's deinit.

@ghost
Copy link
Author

ghost commented Apr 2, 2017

Doesn't seem to work. Could it be because self refers to different things? ChatViewController in my app, and something else in ReverseExtension? I get an error exactly at that specific code now, the one I just inserted in deinit. Maybe you could make a function deinitReverseExtenion(), so that I can call it in viewcontroller's deinit.

@marty-suzuki
Copy link
Owner

I've fixed removeObserver timing at 0.4.2!
Please try it.

@ghost
Copy link
Author

ghost commented Apr 2, 2017

Didn't work.

For further info I am testing it on an actual device, iPhone 6S. Also, outlet is defined as: @IBOutlet var tableView: UITableView! if that makes a difference. I also cleared derived data and cleaned the project.

@marty-suzuki
Copy link
Owner

Do you try this?

tableView.removeObserver(tableView.re, forKeyPath: #keyPath(UITableView.contentInset))

@ghost
Copy link
Author

ghost commented Apr 2, 2017

No didn't. But I just did NOW, and it works!. Thank you.

@marty-suzuki
Copy link
Owner

marty-suzuki commented Apr 3, 2017

I've fixed v0.4.3 without using tableView.removeObserver(tableView.re, forKeyPath: #keyPath(UITableView.contentInset))!

@worthbak
Copy link

worthbak commented Apr 9, 2017

The default version installed via Cocapods (0.4.1) is still affected by this issue.

@marty-suzuki
Copy link
Owner

marty-suzuki commented Apr 9, 2017

Latest version is 0.4.5
Please use that version.

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