Fix for #FB7543829 Apple Radar about a crash on termination #648
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello there,
This is a fix for the problem (FB7543829) with crashes when the user terminates an application when a keyboard has a highlighted suggestion in the accessory view.
The idea behind the fix was taken from this discussion. In general, we set up an observer in the
willMove(toSuperview:)
function but the documentation says explicitly that the function "Tells the view that its superview is about to change to the specified superview". Pay attention to the "is about to change" phrase. So, it is not guaranteed here that thesuperview
will persist.So, to fix the problem I moved the setup of the observer to the
didMoveToSuperview()
and it seems that the change has fixed the problem. After testing it manually, I did not find any problems and the change seems safe and harmless to me.What do you think?