In some edge cases we are observing issues with properly removing the observer because of reliance on superview and isObservingScrollView resulting in observed values getting emitted with no message handler. This ultimately results in a crash.
Changes
Instead of relying on superview to remove the observer we can set the observer ourselves when it gets created. This eliminates the need to check if its of type UIScrollView and also eliminates the need for isObservingScrollView since we can use the class-level observer to check if one is set before removing it
Background
superview
andisObservingScrollView
resulting in observed values getting emitted with no message handler. This ultimately results in a crash.Changes
superview
to remove the observer we can set theobserver
ourselves when it gets created. This eliminates the need to check if its of typeUIScrollView
and also eliminates the need forisObservingScrollView
since we can use the class-levelobserver
to check if one is set before removing it