From 96b269dc5f35f809c76e62d1a230a438b4fea18a Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 14 Jun 2016 23:44:44 +0200 Subject: [PATCH] Documents `<->` internals better. --- RxExample/RxExample/Operators.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/RxExample/RxExample/Operators.swift b/RxExample/RxExample/Operators.swift index f70a2efc..4b376724 100644 --- a/RxExample/RxExample/Operators.swift +++ b/RxExample/RxExample/Operators.swift @@ -51,8 +51,19 @@ func <-> (textInput: RxTextInput, variable: Variable) -> Disposable { let nonMarkedTextValue = nonMarkedText(textInput) - if nonMarkedTextValue != nil && nonMarkedTextValue != variable.value { + /** + In some cases `textInput.textRangeFromPosition(start, toPosition: end)` will return nil even though the underlying + value is not nil. This appears to be an Apple bug. If it's not, and we are doing something wrong, please let us know. + The can be reproed easily if replace bottom code with + + if nonMarkedTextValue != variable.value { variable.value = nonMarkedTextValue ?? "" + } + + and you hit "Done" button on keyboard. + */ + if let nonMarkedTextValue = nonMarkedTextValue where nonMarkedTextValue != variable.value { + variable.value = nonMarkedTextValue } }, onCompleted: { bindToUIDisposable.dispose()