My application uses UITextView to enter text in chat view. I added a placeholder to this by using this answer. The problem occurs when trying to delete longer marked text, then the program falls into infinite loop. For shorter texts the program works correctly and removes selected text. Do you have any idea what might be wrong? How to fix it?
func textViewDidChangeSelection(_ textView: UITextView) {
if placeholderState == .enabled {
if self.window != nil {
textView.selectedTextRange = textView.textRange(from: textView.beginningOfDocument,
to: textView.beginningOfDocument)
}
}
}