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

NSInternalInconsistencyException - UITableView was deallocated while key value observers were still registered with it. #17

Closed
rankinit opened this issue Sep 4, 2015 · 4 comments

Comments

@rankinit
Copy link

rankinit commented Sep 4, 2015

I have a TableViewController that uses Persei. I push the TableViewController when I select a button on my starting view. When I hit the back button in the navigation bar I get the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x7fd003571060> (
<NSKeyValueObservance 0x7fd003576350: Observer: 0x7fd00370e800, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x103111190, Property: 0x7fd00378e3a0>

It looks like in StickyHeaderView is setting the observer here:

public weak var scrollView: UIScrollView! {
    willSet {
        self.scrollView?.removeObserver(self, forKeyPath: "contentOffset", context: &ContentOffsetContext)
        self.scrollView?.panGestureRecognizer.removeTarget(self, action: "handlePan:")

        appliedInsets = UIEdgeInsetsZero
    }

    didSet {
        scrollView?.addObserver(self, forKeyPath: "contentOffset", options: .Initial | .New, context: &ContentOffsetContext)
        scrollView?.panGestureRecognizer.addTarget(self, action: "handlePan:")
    }
}

How can I fix this issue? Thanks!

@dimazen
Copy link
Contributor

dimazen commented Sep 30, 2015

Hell, sorry for the delay, I'll take a look at the next week.

@dimazen
Copy link
Contributor

dimazen commented Oct 23, 2015

Can you upload an example or some code?

@dimazen
Copy link
Contributor

dimazen commented Oct 23, 2015

My rough idea is that willMoveToSuperview is not getting called before UITableView dealloc. A little bit unexpected. Still would like to take a look at some rough sample code. Thanks in advance.

@dimazen
Copy link
Contributor

dimazen commented Nov 13, 2015

@rankinit fixed in 2.0.1

@dimazen dimazen closed this as completed Nov 13, 2015
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