IBScrollViewFloatingHeader icon indicating copy to clipboard operation
IBScrollViewFloatingHeader copied to clipboard

KVO are not deleted when the tableview is delete

Open jerometonnelier opened this issue 11 years ago • 5 comments

2014-07-29 16:20:41.977 RG[15786:60b] An instance 0xe0b6600 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 0xc276520> ( <NSKeyValueObservance 0xc276600: Observer: 0xe0b6600, Key path: contentOffset, Options: <New: YES, Old: YES, Prior: NO> Context: 0x253784, Property: 0xc276500> )

jerometonnelier avatar Jul 29 '14 14:07 jerometonnelier

I'm also experiencing this problem. Basically an observer is getting set for the floating header (obviously), but doesn't get removed before the tableview is deallocated from the memory. I tried fixing this by implementing a "dealloc" method, or a "remove observer" method inside the floating header's class and having my View Controller call it inside its own "dealloc" or "viewWillDissapear" methods. Sadly, no luck. In all scenarios, either the problem persists, or the app crashes.

Any updates on this?

orenk86 avatar Aug 13 '14 14:08 orenk86

+1 I am also experiencing this problem

paulius005 avatar Jan 21 '15 21:01 paulius005

viewWillDisappear is called before memory teardown, so that may be the place to remove whatever is not being removed in the UIViewController.

paulius005 avatar Jan 22 '15 00:01 paulius005

[self addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:IBFloatingHeaderViewContext];

This seems to be the observer that should be removed

paulius005 avatar Jan 22 '15 01:01 paulius005

Figured it out.

Need this: -(void)removeContentOffsetObserver { [self removeObserver:self forKeyPath:@"contentOffset" context:IBFloatingHeaderViewContext]; }

Will fork and submit pull request

paulius005 avatar Jan 22 '15 01:01 paulius005