App crashes with error "Fatal Exception: NSInvalidArgumentException -[<NSTextContentStorage: 0x281dc68a0> locationFromLocation:withOffset:] received invalid location (null)"

From iOS 16 onwards my app which uses UITextView in iOS for editing, started crashing for a number of users with error.

App crashes with error "Fatal Exception: NSInvalidArgumentException -[<NSTextContentStorage: 0x281dc68a0> locationFromLocation:withOffset:] received invalid location (null)"

App crashes with error "Fatal Exception: NSInvalidArgumentException -[&lt;NSTextContentStorage: 0x281dc68a0&gt; locationFromLocation:withOffset:] received invalid location (null)"
 
 
Q