Observation info was leaked
Closed this issue · 4 comments
Just a heads up that I believe there is an issue with an observer not being removed. In my app, this crops up after this sequence
- segue from a PullToRefresh tableview to a secondary viewcontroller
- segue from the secondary viewcontroller to another instance of a PullToRefresh tableview
- upon clicking in my navigation control to go "Back" the following shows up in the console...
An instance 0x8c7ee00 of class UITableView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
<NSKeyValueObservationInfo 0x81a4300> (
<NSKeyValueObservance 0x81a3df0: Observer: 0x81a5910, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x8178220>
Another PullToRefresh version has a similar issue after searching around (https://github.com/chpwn/PullToRefreshView/issues/6) and after adding in some things I got it working without the console warnings.
Fix -
in PullToRefreshView.m file add this to under dealloc...
- (void)containingViewDidUnload {
[scrollView removeObserver:self forKeyPath:@"contentOffset"];
scrollView = nil;
}
in PullToRefreshView.h add this to somewhere in the PullToRefreshView interface
- (void)containingViewDidUnload;
in the file that implements the PullToRefresh feature add
- (void)viewDidUnload
{
[pull containingViewDidUnload];
[super viewDidUnload];
} - (void)dealloc
{
[pull containingViewDidUnload];
}
I'm also running into this. I'm actually getting crashes due to it.
Removed weak references, should be fixed now.
@sonnyparlin I'm having the same issue. Pull TO Refresh code is creating problems. Can I have the updated code for the same ?