Returning false in shouldChangeTextInRange method auto capitalize all letters

Try scheduling this assignment statement in a main loop:

    textView.text = newString

becomes:

    DispatchQueue.main.async {
        textView.text = newString
    }

This successfully worked around a similar issue for me where the first two letters of the sentence were being capitalized. My best guess is that the logic behind the didSet listener for the UITextView's text property changed in a way that immediately fires the delegate synchronously. Scheduling the assignment asynchronously on the main queue forces/guarantees the delegate returns before being fired that second time.


The best workaround that I have found so far is to do the processing in textViewDidChange instead.

The bug is also discussed here: Apple developer forum