From 0c11d8d9b4edf7830255f5b016d0ba7ef72ae827 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 13 May 2019 13:14:45 -0700 Subject: [PATCH] Back out "[react-native][PR] [iOS] Fixes selection of single line text input" Summary: Original commit changeset: f149721d6b4d (D15238379) This commit was causing the following crash: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7fb3453eda00 of class RCTUITextField was deallocated while key value observers were still registered with it. FB: See also P64445585 T44107377 T44169319 Reviewed By: mmmulani Differential Revision: D15323255 fbshipit-source-id: 037c34ae387d912c5ea03eaa364b8c60367df357 --- .../TextInput/RCTBackedTextInputDelegateAdapter.m | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m index 8cbca2936c00ea..fe5ee67647d950 100644 --- a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +++ b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m @@ -28,27 +28,15 @@ - (instancetype)initWithTextField:(UITextField * [_backedTextInputView addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged]; [_backedTextInputView addTarget:self action:@selector(textFieldDidEndEditingOnExit) forControlEvents:UIControlEventEditingDidEndOnExit]; - [_backedTextInputView addObserver:self forKeyPath:@"selectedTextRange" options:NSKeyValueObservingOptionNew context:NULL]; } return self; } -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - // UITextField doesn't have a delegate like UITextView to get notified on selection. Use KVO to observe changes. - if ([keyPath isEqualToString:@"selectedTextRange"]) { - [self textFieldProbablyDidChangeSelection]; - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - - (void)dealloc { [_backedTextInputView removeTarget:self action:nil forControlEvents:UIControlEventEditingChanged]; [_backedTextInputView removeTarget:self action:nil forControlEvents:UIControlEventEditingDidEndOnExit]; - [_backedTextInputView removeObserver:self forKeyPath:@"selectedTextRange"]; } #pragma mark - UITextFieldDelegate